From 8bc33895d1bb04adcefee405746ef3c21d99a66d Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 17 Sep 2019 15:36:33 +0300 Subject: [PATCH] Fix an unsigned overflow error in Text --- source/text.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/text.cpp b/source/text.cpp index 1d824e0..45b6567 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -123,8 +123,9 @@ unsigned Text::get_visible_lines(const Part &part, const Geometry &parent, unsig unsigned line_spacing = static_cast(font_size*6/5); const Sides &margin = part.get_margin(); - unsigned vmargin = margin.top+margin.bottom+line_height-line_spacing; - unsigned n_lines = min(lines.size(), max((max(parent.h, vmargin)-vmargin)/line_spacing, 1U)); + unsigned vmargin = margin.top+margin.bottom; + unsigned free_height = max(parent.h, vmargin)-vmargin+line_spacing-line_height; + unsigned n_lines = min(lines.size(), max(free_height/line_spacing, 1U)); if(fit_height) *fit_height = line_height+(n_lines-1)*line_spacing; -- 2.45.2