Changeset - r28162:594ad3dc2dc9
[Not reviewed]
master
0 1 0
Peter Nelson - 7 months ago 2023-11-20 22:22:23
peter1138@openttd.org
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.
1 file changed with 1 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/gfx.cpp
Show inline comments
 
@@ -693,6 +693,7 @@ int DrawString(int left, int right, int 
 
 */
 
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
 
{
 
	assert(maxw > 0);
 
	Layouter layout(str, maxw, TC_FROMSTRING, fontsize);
 
	return layout.GetBounds().height;
 
}
0 comments (0 inline, 0 general)