From a7ea8682828760f909f9e4a9efdd5af29466889d Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 25 Feb 2022 11:04:36 -0800 Subject: [PATCH] Avoid overflow in textbox Count() returns unsigned values. Since, we subtract 1 from this value, if the count is 0, we will underflow the unsigned value, creating an extremely large value that we multiply by the interline spacing. (cherry picked from commit d29d9817840a862785819a5de09c73e429c33307) --- common/eda_text.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 3a9eb6393b..53cb659bb2 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -574,7 +574,9 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const // interline spacing is only *between* lines, so total height is the height of the first // line plus the interline distance (with interline spacing) for all subsequent lines - textsize.y += KiROUND( ( strings.GetCount() - 1 ) * font->GetInterline( fontSize.y ) ); + // Don't add interline spacing to empty textboxes + if( strings.GetCount() ) + textsize.y += KiROUND( ( strings.GetCount() - 1 ) * font->GetInterline( fontSize.y ) ); } rect.SetSize( textsize );