mirror of https://github.com/OpenTTD/OpenTTD
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.pull/11481/head
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)
|
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
|
||||||
{
|
{
|
||||||
|
assert(maxw > 0);
|
||||||
Layouter layout(str, maxw, TC_FROMSTRING, fontsize);
|
Layouter layout(str, maxw, TC_FROMSTRING, fontsize);
|
||||||
return layout.GetBounds().height;
|
return layout.GetBounds().height;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue