[0.4.14][NTGDI] Check if face->charmap is not zero before accessing its encoding (#4390)

Prevents a BSOD 0x1E upon dereference.
CORE-18091 CORE-18558

By partially porting back:
0.4.15-dev-5587-ga999c43 a999c43746
and take also some cosmetic changes from master head, like EOL-whitespace-removal.
This commit is contained in:
Joachim Henze 2023-01-21 11:06:56 +01:00
parent 69eb10692a
commit 497261a758

View file

@ -2197,9 +2197,7 @@ FillTM(TEXTMETRICW *TM, PFONTGDI FontGDI,
TM->tmAveCharWidth = (FT_MulFix(pOS2->xAvgCharWidth, XScale) + 32) >> 6;
if (TM->tmAveCharWidth == 0)
{
TM->tmAveCharWidth = 1;
}
/* Correct forumla to get the maxcharwidth from unicode and ansi font */
TM->tmMaxCharWidth = (FT_MulFix(Face->max_advance_width, XScale) + 32) >> 6;
@ -4477,6 +4475,9 @@ ftGetFontUnicodeRanges(PFONTGDI Font, PGLYPHSET glyphset)
DWORD num_ranges = 0;
FT_Face face = Font->SharedFace->Face;
if (face->charmap == NULL)
return 0;
if (face->charmap->encoding == FT_ENCODING_UNICODE)
{
FT_UInt glyph_code = 0;
@ -6438,15 +6439,14 @@ IntExtTextOutW(
HSourceGlyph = EngCreateBitmap(bitSize, realglyph->bitmap.pitch,
BMF_8BPP, BMF_TOPDOWN,
realglyph->bitmap.buffer);
if ( !HSourceGlyph )
if (!HSourceGlyph)
{
DPRINT1("WARNING: EngCreateBitmap() failed!\n");
// FT_Done_Glyph(realglyph);
bResult = FALSE;
break;
}
SourceGlyphSurf = EngLockSurface((HSURF)HSourceGlyph);
if ( !SourceGlyphSurf )
if (!SourceGlyphSurf)
{
EngDeleteSurface((HSURF)HSourceGlyph);
DPRINT1("WARNING: EngLockSurface() failed!\n");
@ -6586,7 +6586,6 @@ IntExtTextOutW(
EXLATEOBJ_vCleanup(&exloDst2RGB);
Cleanup:
DC_vFinishBlit(dc, NULL);
if (TextObj != NULL)