Fix buffer overflow when getting text extents

lfFaceName needs to be null-terminated, so only copy up to 31 characters
into the buffer.
This commit is contained in:
Thomas Goyne 2014-07-08 09:21:13 -07:00
parent 8a5b4ae3a3
commit e60197962a
1 changed files with 1 additions and 1 deletions

View File

@ -86,7 +86,7 @@ namespace Automation4 {
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfQuality = ANTIALIASED_QUALITY;
lf.lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE;
wcsncpy(lf.lfFaceName, agi::charset::ConvertW(style->font).c_str(), 32);
wcsncpy(lf.lfFaceName, agi::charset::ConvertW(style->font).c_str(), 31);
HFONT thefont = CreateFontIndirect(&lf);
if (!thefont) return false;