From dfab9fc0668be2b3a3bcb55a8c2c2c49d58c3308 Mon Sep 17 00:00:00 2001 From: najeira Date: Tue, 24 Jul 2018 01:38:13 +0900 Subject: [PATCH] libtxt: fix a bug that used incorrect buffer size depending on conditions (flutter/engine#5804) * libtxt: fix a bug that used incorrect buffer size depending on conditions * Update AUTHORS * clang-format --- engine/src/flutter/AUTHORS | 1 + engine/src/flutter/third_party/txt/src/txt/paragraph.cc | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/AUTHORS b/engine/src/flutter/AUTHORS index bd94ff3fe6..ddcf4d7bd4 100644 --- a/engine/src/flutter/AUTHORS +++ b/engine/src/flutter/AUTHORS @@ -11,3 +11,4 @@ Dan Field Victor Choueiri Simon Lightfoot Dwayne Slater +Tetsuhiro Ueda diff --git a/engine/src/flutter/third_party/txt/src/txt/paragraph.cc b/engine/src/flutter/third_party/txt/src/txt/paragraph.cc index 78aa0911d3..e034bc5df7 100644 --- a/engine/src/flutter/third_party/txt/src/txt/paragraph.cc +++ b/engine/src/flutter/third_party/txt/src/txt/paragraph.cc @@ -504,6 +504,7 @@ void Paragraph::Layout(double width, bool force) { uint16_t* text_ptr = text_.data(); size_t text_start = run.start(); size_t text_count = run.end() - run.start(); + size_t text_size = text_.size(); // Apply ellipsizing if the run was not completely laid out and this // is the last line (or lines are unlimited). @@ -541,6 +542,7 @@ void Paragraph::Layout(double width, bool force) { text_ptr = ellipsized_text.data(); text_start = 0; text_count = ellipsized_text.size(); + text_size = text_count; // If there is no line limit, then skip all lines after the ellipsized // line. @@ -550,9 +552,8 @@ void Paragraph::Layout(double width, bool force) { } } - layout.doLayout(text_ptr, text_start, text_count, text_.size(), - run.is_rtl(), font, minikin_paint, - minikin_font_collection); + layout.doLayout(text_ptr, text_start, text_count, text_size, run.is_rtl(), + font, minikin_paint, minikin_font_collection); if (layout.nGlyphs() == 0) continue;