[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; TM->tmAveCharWidth = (FT_MulFix(pOS2->xAvgCharWidth, XScale) + 32) >> 6;
if (TM->tmAveCharWidth == 0) if (TM->tmAveCharWidth == 0)
{
TM->tmAveCharWidth = 1; TM->tmAveCharWidth = 1;
}
/* Correct forumla to get the maxcharwidth from unicode and ansi font */ /* Correct forumla to get the maxcharwidth from unicode and ansi font */
TM->tmMaxCharWidth = (FT_MulFix(Face->max_advance_width, XScale) + 32) >> 6; TM->tmMaxCharWidth = (FT_MulFix(Face->max_advance_width, XScale) + 32) >> 6;
@ -4477,6 +4475,9 @@ ftGetFontUnicodeRanges(PFONTGDI Font, PGLYPHSET glyphset)
DWORD num_ranges = 0; DWORD num_ranges = 0;
FT_Face face = Font->SharedFace->Face; FT_Face face = Font->SharedFace->Face;
if (face->charmap == NULL)
return 0;
if (face->charmap->encoding == FT_ENCODING_UNICODE) if (face->charmap->encoding == FT_ENCODING_UNICODE)
{ {
FT_UInt glyph_code = 0; FT_UInt glyph_code = 0;
@ -6441,7 +6442,6 @@ IntExtTextOutW(
if (!HSourceGlyph) if (!HSourceGlyph)
{ {
DPRINT1("WARNING: EngCreateBitmap() failed!\n"); DPRINT1("WARNING: EngCreateBitmap() failed!\n");
// FT_Done_Glyph(realglyph);
bResult = FALSE; bResult = FALSE;
break; break;
} }
@ -6586,7 +6586,6 @@ IntExtTextOutW(
EXLATEOBJ_vCleanup(&exloDst2RGB); EXLATEOBJ_vCleanup(&exloDst2RGB);
Cleanup: Cleanup:
DC_vFinishBlit(dc, NULL); DC_vFinishBlit(dc, NULL);
if (TextObj != NULL) if (TextObj != NULL)