gdi32: Zero pad the facename buffer so that we don't write uninitialized data to the metafile.
Found by Valgrind.
This commit is contained in:
parent
4f1d040eaf
commit
1ff1e11161
|
@ -365,6 +365,7 @@ static UINT16 MFDRV_CreateFontIndirect(PHYSDEV dev, HFONT hFont, LOGFONTW *logfo
|
||||||
char buffer[sizeof(METARECORD) - 2 + sizeof(LOGFONT16)];
|
char buffer[sizeof(METARECORD) - 2 + sizeof(LOGFONT16)];
|
||||||
METARECORD *mr = (METARECORD *)&buffer;
|
METARECORD *mr = (METARECORD *)&buffer;
|
||||||
LOGFONT16 *font16;
|
LOGFONT16 *font16;
|
||||||
|
INT written;
|
||||||
|
|
||||||
mr->rdSize = (sizeof(METARECORD) + sizeof(LOGFONT16) - 2) / 2;
|
mr->rdSize = (sizeof(METARECORD) + sizeof(LOGFONT16) - 2) / 2;
|
||||||
mr->rdFunction = META_CREATEFONTINDIRECT;
|
mr->rdFunction = META_CREATEFONTINDIRECT;
|
||||||
|
@ -383,8 +384,9 @@ static UINT16 MFDRV_CreateFontIndirect(PHYSDEV dev, HFONT hFont, LOGFONTW *logfo
|
||||||
font16->lfClipPrecision = logfont->lfClipPrecision;
|
font16->lfClipPrecision = logfont->lfClipPrecision;
|
||||||
font16->lfQuality = logfont->lfQuality;
|
font16->lfQuality = logfont->lfQuality;
|
||||||
font16->lfPitchAndFamily = logfont->lfPitchAndFamily;
|
font16->lfPitchAndFamily = logfont->lfPitchAndFamily;
|
||||||
WideCharToMultiByte( CP_ACP, 0, logfont->lfFaceName, -1, font16->lfFaceName, LF_FACESIZE, NULL, NULL );
|
written = WideCharToMultiByte( CP_ACP, 0, logfont->lfFaceName, -1, font16->lfFaceName, LF_FACESIZE - 1, NULL, NULL );
|
||||||
font16->lfFaceName[LF_FACESIZE-1] = 0;
|
/* Zero pad the facename buffer, so that we don't write uninitialized data to disk */
|
||||||
|
memset(font16->lfFaceName + written, 0, LF_FACESIZE - written);
|
||||||
|
|
||||||
if (!(MFDRV_WriteRecord( dev, mr, mr->rdSize * 2)))
|
if (!(MFDRV_WriteRecord( dev, mr, mr->rdSize * 2)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue