Codechange: Assert that max width passed to GetStringHeight is non-zero.
Max width of zero will cause text layouters to crash, potentially after exhausting memory first.
This commit is contained in:

committed by
Peter Nelson

parent
0578b8eaa9
commit
d04fd4602d
@@ -693,6 +693,7 @@ int DrawString(int left, int right, int top, StringID str, TextColour colour, St
|
||||
*/
|
||||
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
|
||||
{
|
||||
assert(maxw > 0);
|
||||
Layouter layout(str, maxw, TC_FROMSTRING, fontsize);
|
||||
return layout.GetBounds().height;
|
||||
}
|
||||
|
Reference in New Issue
Block a user