зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1430552 - Handle possible freetype failures in gfxFT2FontBase::GetFTGlyphAdvance to avoid risk of crashes. r=lsalzman
This commit is contained in:
Родитель
41d4da5cef
Коммит
e164d9c087
|
@ -511,14 +511,22 @@ FT_Fixed
|
||||||
gfxFT2FontBase::GetFTGlyphAdvance(uint16_t aGID)
|
gfxFT2FontBase::GetFTGlyphAdvance(uint16_t aGID)
|
||||||
{
|
{
|
||||||
gfxFT2LockedFace face(this);
|
gfxFT2LockedFace face(this);
|
||||||
|
MOZ_ASSERT(face.get());
|
||||||
|
if (!face.get()) {
|
||||||
|
// Failed to get the FT_Face? Give up already.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
int32_t flags =
|
int32_t flags =
|
||||||
gfxPlatform::GetPlatform()->FontHintingEnabled()
|
gfxPlatform::GetPlatform()->FontHintingEnabled()
|
||||||
? FT_LOAD_ADVANCE_ONLY
|
? FT_LOAD_ADVANCE_ONLY
|
||||||
: FT_LOAD_ADVANCE_ONLY | FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING;
|
: FT_LOAD_ADVANCE_ONLY | FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING;
|
||||||
FT_Fixed advance = 0;
|
FT_Error ftError = FT_Load_Glyph(face.get(), aGID, flags);
|
||||||
mozilla::DebugOnly<FT_Error> ftError =
|
|
||||||
FT_Load_Glyph(face.get(), aGID, flags);
|
|
||||||
MOZ_ASSERT(!ftError);
|
MOZ_ASSERT(!ftError);
|
||||||
|
if (ftError != FT_Err_Ok) {
|
||||||
|
// FT_Face was somehow broken/invalid? Don't try to access glyph slot.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
FT_Fixed advance = 0;
|
||||||
if (face.get()->face_flags & FT_FACE_FLAG_SCALABLE) {
|
if (face.get()->face_flags & FT_FACE_FLAG_SCALABLE) {
|
||||||
advance = face.get()->glyph->linearHoriAdvance;
|
advance = face.get()->glyph->linearHoriAdvance;
|
||||||
} else {
|
} else {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче