From d29d9817840a862785819a5de09c73e429c33307 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. --- 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 5742f6c229..8d3b33eb9a 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -316,7 +316,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 ) * interline ); + // Don't add interline spacing to empty textboxes + if( strings.GetCount() ) + textsize.y += KiROUND( ( strings.GetCount() - 1 ) * interline ); } rect.SetSize( textsize );