mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-24 20:12:42 +00:00
Codefix: Potential unterminated string returned from convert_to_fs.
Converting from UTF-8 to UTF-16 could have resulted in a buffer overflow if the buffer size was exactly the length of the converted string. Pass string_view/span to convert_from/to_fs instead, and ensure the buffer is terminated. This replaces passing a pointer to the buffer and the buffer size as separate parameters, allowing the compiler to pass both in one parameter. Removes use of `lengthof()`.
This commit is contained in:
committed by
Peter Nelson
parent
b37954722b
commit
e2a796dbcd
@@ -147,7 +147,7 @@ static HFONT HFontFromFont(Font *font)
|
||||
logfont.lfHeight = font->fc->GetHeight();
|
||||
logfont.lfWeight = FW_NORMAL;
|
||||
logfont.lfCharSet = DEFAULT_CHARSET;
|
||||
convert_to_fs(font->fc->GetFontName(), logfont.lfFaceName, lengthof(logfont.lfFaceName));
|
||||
convert_to_fs(font->fc->GetFontName(), logfont.lfFaceName);
|
||||
|
||||
return CreateFontIndirect(&logfont);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user