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:
Peter Nelson 2023-11-20 22:22:23 +00:00 committed by Peter Nelson
parent 0578b8eaa9
commit d04fd4602d

View File

@ -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;
}