mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 00:27:13 +00:00
[0.4.9][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:
parent
8a9c4b374e
commit
96db0cd726
1 changed files with 13 additions and 24 deletions
|
@ -1242,7 +1242,6 @@ IntGdiAddFontMemResource(PVOID Buffer, DWORD dwSize, PDWORD pNumAdded)
|
||||||
HANDLE Ret = 0;
|
HANDLE Ret = 0;
|
||||||
|
|
||||||
PVOID BufferCopy = ExAllocatePoolWithTag(PagedPool, dwSize, TAG_FONT);
|
PVOID BufferCopy = ExAllocatePoolWithTag(PagedPool, dwSize, TAG_FONT);
|
||||||
|
|
||||||
if (!BufferCopy)
|
if (!BufferCopy)
|
||||||
{
|
{
|
||||||
*pNumAdded = 0;
|
*pNumAdded = 0;
|
||||||
|
@ -1552,7 +1551,6 @@ static BOOL face_has_symbol_charmap(FT_Face ft_face)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void FASTCALL
|
static void FASTCALL
|
||||||
FillTMEx(TEXTMETRICW *TM, PFONTGDI FontGDI,
|
FillTMEx(TEXTMETRICW *TM, PFONTGDI FontGDI,
|
||||||
TT_OS2 *pOS2, TT_HoriHeader *pHori,
|
TT_OS2 *pOS2, TT_HoriHeader *pHori,
|
||||||
|
@ -1633,9 +1631,7 @@ FillTMEx(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;
|
||||||
|
@ -3173,7 +3169,6 @@ ftGdiGetGlyphOutline(
|
||||||
|
|
||||||
FT_Matrix ftmatrix;
|
FT_Matrix ftmatrix;
|
||||||
FLOATOBJ efTemp;
|
FLOATOBJ efTemp;
|
||||||
|
|
||||||
PMATRIX pmx = DC_pmxWorldToDevice(dc);
|
PMATRIX pmx = DC_pmxWorldToDevice(dc);
|
||||||
|
|
||||||
/* Create a freetype matrix, by converting to 16.16 fixpoint format */
|
/* Create a freetype matrix, by converting to 16.16 fixpoint format */
|
||||||
|
@ -3770,6 +3765,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;
|
||||||
|
@ -4481,9 +4479,6 @@ TextIntRealizeFont(HFONT FontHandle, PTEXTOBJ pTextObj)
|
||||||
FontGdi->RequestWeight = FW_NORMAL;
|
FontGdi->RequestWeight = FW_NORMAL;
|
||||||
|
|
||||||
Face = FontGdi->SharedFace->Face;
|
Face = FontGdi->SharedFace->Face;
|
||||||
|
|
||||||
//FontGdi->OriginalWeight = WeightFromStyle(Face->style_name);
|
|
||||||
|
|
||||||
if (!FontGdi->OriginalItalic)
|
if (!FontGdi->OriginalItalic)
|
||||||
FontGdi->OriginalItalic = ItalicFromStyle(Face->style_name);
|
FontGdi->OriginalItalic = ItalicFromStyle(Face->style_name);
|
||||||
|
|
||||||
|
@ -5664,15 +5659,14 @@ GreExtTextOutW(
|
||||||
HSourceGlyph = EngCreateBitmap(bitSize, realglyph->bitmap.pitch,
|
HSourceGlyph = EngCreateBitmap(bitSize, realglyph->bitmap.pitch,
|
||||||
BMF_8BPP, BMF_TOPDOWN,
|
BMF_8BPP, BMF_TOPDOWN,
|
||||||
realglyph->bitmap.buffer);
|
realglyph->bitmap.buffer);
|
||||||
if ( !HSourceGlyph )
|
if (!HSourceGlyph)
|
||||||
{
|
{
|
||||||
DPRINT1("WARNING: EngCreateBitmap() failed!\n");
|
DPRINT1("WARNING: EngCreateBitmap() failed!\n");
|
||||||
// FT_Done_Glyph(realglyph);
|
|
||||||
bResult = FALSE;
|
bResult = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SourceGlyphSurf = EngLockSurface((HSURF)HSourceGlyph);
|
SourceGlyphSurf = EngLockSurface((HSURF)HSourceGlyph);
|
||||||
if ( !SourceGlyphSurf )
|
if (!SourceGlyphSurf)
|
||||||
{
|
{
|
||||||
EngDeleteSurface((HSURF)HSourceGlyph);
|
EngDeleteSurface((HSURF)HSourceGlyph);
|
||||||
DPRINT1("WARNING: EngLockSurface() failed!\n");
|
DPRINT1("WARNING: EngLockSurface() failed!\n");
|
||||||
|
@ -5812,7 +5806,6 @@ GreExtTextOutW(
|
||||||
EXLATEOBJ_vCleanup(&exloDst2RGB);
|
EXLATEOBJ_vCleanup(&exloDst2RGB);
|
||||||
|
|
||||||
Cleanup:
|
Cleanup:
|
||||||
|
|
||||||
DC_vFinishBlit(dc, NULL);
|
DC_vFinishBlit(dc, NULL);
|
||||||
|
|
||||||
if (TextObj != NULL)
|
if (TextObj != NULL)
|
||||||
|
@ -6146,7 +6139,7 @@ NtGdiGetCharABCWidthsW(
|
||||||
if(Safepwch)
|
if(Safepwch)
|
||||||
ExFreePoolWithTag(Safepwch , GDITAG_TEXT);
|
ExFreePoolWithTag(Safepwch , GDITAG_TEXT);
|
||||||
|
|
||||||
if (! NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastNtError(Status);
|
SetLastNtError(Status);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -6394,7 +6387,6 @@ NtGdiGetGlyphIndicesW(
|
||||||
{
|
{
|
||||||
return GDI_ERROR;
|
return GDI_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
FontGDI = ObjToGDI(TextObj->Font, FONT);
|
FontGDI = ObjToGDI(TextObj->Font, FONT);
|
||||||
TEXTOBJ_UnlockText(TextObj);
|
TEXTOBJ_UnlockText(TextObj);
|
||||||
|
|
||||||
|
@ -6434,7 +6426,6 @@ NtGdiGetGlyphIndicesW(
|
||||||
|
|
||||||
pwcSize = cwc * sizeof(WCHAR);
|
pwcSize = cwc * sizeof(WCHAR);
|
||||||
Safepwc = ExAllocatePoolWithTag(PagedPool, pwcSize, GDITAG_TEXT);
|
Safepwc = ExAllocatePoolWithTag(PagedPool, pwcSize, GDITAG_TEXT);
|
||||||
|
|
||||||
if (!Safepwc)
|
if (!Safepwc)
|
||||||
{
|
{
|
||||||
Status = STATUS_NO_MEMORY;
|
Status = STATUS_NO_MEMORY;
|
||||||
|
@ -6455,7 +6446,6 @@ NtGdiGetGlyphIndicesW(
|
||||||
if (!NT_SUCCESS(Status)) goto ErrorRet;
|
if (!NT_SUCCESS(Status)) goto ErrorRet;
|
||||||
|
|
||||||
IntLockFreeType;
|
IntLockFreeType;
|
||||||
|
|
||||||
for (i = 0; i < cwc; i++)
|
for (i = 0; i < cwc; i++)
|
||||||
{
|
{
|
||||||
Buffer[i] = FT_Get_Char_Index(FontGDI->SharedFace->Face, Safepwc[i]);
|
Buffer[i] = FT_Get_Char_Index(FontGDI->SharedFace->Face, Safepwc[i]);
|
||||||
|
@ -6464,7 +6454,6 @@ NtGdiGetGlyphIndicesW(
|
||||||
Buffer[i] = DefChar;
|
Buffer[i] = DefChar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IntUnLockFreeType;
|
IntUnLockFreeType;
|
||||||
|
|
||||||
_SEH2_TRY
|
_SEH2_TRY
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue