Bug 1584856 - patch 1 - Add some missing null-checks in dwrite font code. r=lsalzman
authorJonathan Kew <jkew@mozilla.com>
Tue, 01 Oct 2019 20:35:28 +0000
changeset 496000 fcd8b94fdd4b3ef3236ea09bf16b1b5a0cfe73b5
parent 495999 7bede01766e0fdd0520a2c318b6859a2aae3145f
child 496001 a7c4367d186d46f55a1adce7dd03ac7ef2a393e2
push id114140
push userdvarga@mozilla.com
push dateWed, 02 Oct 2019 18:04:51 +0000
treeherdermozilla-inbound@32eb0ea893f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1584856
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1584856 - patch 1 - Add some missing null-checks in dwrite font code. r=lsalzman Differential Revision: https://phabricator.services.mozilla.com/D47788
gfx/thebes/gfxDWriteFontList.cpp
gfx/thebes/gfxPlatformFontList.cpp
--- a/gfx/thebes/gfxDWriteFontList.cpp
+++ b/gfx/thebes/gfxDWriteFontList.cpp
@@ -936,18 +936,24 @@ gfxFontEntry* gfxDWriteFontList::CreateF
   IDWriteFontCollection* collection =
 #ifdef MOZ_BUNDLED_FONTS
       aFamily->IsBundled() ? mBundledFonts : mSystemFonts;
 #else
       mSystemFonts;
 #endif
   RefPtr<IDWriteFontFamily> family;
   collection->GetFontFamily(aFamily->Index(), getter_AddRefs(family));
+  if (!family) {
+    return nullptr;
+  }
   RefPtr<IDWriteFont> font;
   family->GetFont(aFace->mIndex, getter_AddRefs(font));
+  if (!font) {
+    return nullptr;
+  }
   nsAutoCString faceName;
   HRESULT hr = GetDirectWriteFontName(font, faceName);
   if (FAILED(hr)) {
     return nullptr;
   }
   auto fe = new gfxDWriteFontEntry(faceName, font, !aFamily->IsBundled());
   fe->mStyleRange = aFace->mStyle;
   fe->mStretchRange = aFace->mStretch;
@@ -996,17 +1002,17 @@ void gfxDWriteFontList::GetFacesInitData
   if (!collection) {
     return;
   }
   RefPtr<IDWriteFontFamily> family;
   collection->GetFontFamily(aFamily->Index(), getter_AddRefs(family));
   for (unsigned i = 0; i < family->GetFontCount(); ++i) {
     RefPtr<IDWriteFont> dwFont;
     family->GetFont(i, getter_AddRefs(dwFont));
-    if (dwFont->GetSimulations() != DWRITE_FONT_SIMULATIONS_NONE) {
+    if (!dwFont || dwFont->GetSimulations() != DWRITE_FONT_SIMULATIONS_NONE) {
       continue;
     }
     DWRITE_FONT_STYLE dwstyle = dwFont->GetStyle();
     // Ignore italic styles of Meiryo because "Meiryo (Bold) Italic" has
     // non-italic style glyphs as Japanese characters.  However, using it
     // causes serious problem if web pages wants some elements to be
     // different style from others only with font-style.  For example,
     // <em> and <i> should be rendered as italic in the default style.
--- a/gfx/thebes/gfxPlatformFontList.cpp
+++ b/gfx/thebes/gfxPlatformFontList.cpp
@@ -441,16 +441,19 @@ nsresult gfxPlatformFontList::InitFontLi
 
   sPlatformFontList = this;
 
   // Try to initialize the cross-process shared font list if enabled by prefs,
   // but not if we're running in Safe Mode.
   if (StaticPrefs::gfx_e10s_font_list_shared_AtStartup() &&
       !gfxPlatform::InSafeMode()) {
     for (auto i = mFontEntries.Iter(); !i.Done(); i.Next()) {
+      if (!i.Data()) {
+        continue;
+      }
       i.Data()->mShmemCharacterMap = nullptr;
       i.Data()->mShmemFace = nullptr;
       i.Data()->mFamilyName = NS_LITERAL_CSTRING("");
     }
     mFontEntries.Clear();
     mShmemCharMaps.Clear();
     bool oldSharedList = mSharedFontList != nullptr;
     mSharedFontList.reset(new fontlist::FontList(mFontlistInitCount));