Bug 1556481 - check for DWrite failures in UnscaledFontDWrite::GetFontFileData. r=jfkthame
authorLee Salzman <lsalzman@mozilla.com>
Tue, 04 Jun 2019 09:26:11 +0000
changeset 476837 50727795c336ed1cb7571be95af7a4679035d9a3
parent 476836 5f04783422b4f522bf28ad1bb62c9baf0980650b
child 476838 9cf36b46d6c3b52274bde46327ad82534178b339
push id36108
push usernbeleuzu@mozilla.com
push dateTue, 04 Jun 2019 21:42:40 +0000
treeherdermozilla-central@ebe7fdd19be5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1556481
milestone69.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 1556481 - check for DWrite failures in UnscaledFontDWrite::GetFontFileData. r=jfkthame Differential Revision: https://phabricator.services.mozilla.com/D33585
gfx/2d/ScaledFontDWrite.cpp
--- a/gfx/2d/ScaledFontDWrite.cpp
+++ b/gfx/2d/ScaledFontDWrite.cpp
@@ -265,55 +265,70 @@ void ScaledFontDWrite::CopyGlyphsToSink(
     gfxCriticalNote << "Failed to copy glyphs to geometry sink. Code: "
                     << hexa(hr);
   }
 }
 
 bool UnscaledFontDWrite::GetFontFileData(FontFileDataOutput aDataCallback,
                                          void* aBaton) {
   UINT32 fileCount = 0;
-  mFontFace->GetFiles(&fileCount, nullptr);
+  HRESULT hr = mFontFace->GetFiles(&fileCount, nullptr);
 
-  if (fileCount > 1) {
+  if (FAILED(hr) || fileCount > 1) {
     MOZ_ASSERT(false);
     return false;
   }
 
   if (!aDataCallback) {
     return true;
   }
 
   RefPtr<IDWriteFontFile> file;
-  mFontFace->GetFiles(&fileCount, getter_AddRefs(file));
+  hr = mFontFace->GetFiles(&fileCount, getter_AddRefs(file));
+  if (FAILED(hr)) {
+    return false;
+  }
 
   const void* referenceKey;
   UINT32 refKeySize;
   // XXX - This can currently crash for webfonts, as when we get the reference
   // key out of the file, that can be an invalid reference key for the loader
   // we use it with. The fix to this is not obvious but it will probably
   // have to happen inside thebes.
-  file->GetReferenceKey(&referenceKey, &refKeySize);
+  hr = file->GetReferenceKey(&referenceKey, &refKeySize);
+  if (FAILED(hr)) {
+    return false;
+  }
 
   RefPtr<IDWriteFontFileLoader> loader;
-  file->GetLoader(getter_AddRefs(loader));
+  hr = file->GetLoader(getter_AddRefs(loader));
+  if (FAILED(hr)) {
+    return false;
+  }
 
   RefPtr<IDWriteFontFileStream> stream;
-  loader->CreateStreamFromKey(referenceKey, refKeySize, getter_AddRefs(stream));
+  hr = loader->CreateStreamFromKey(referenceKey, refKeySize, getter_AddRefs(stream));
+  if (FAILED(hr)) {
+    return false;
+  }
 
   UINT64 fileSize64;
-  stream->GetFileSize(&fileSize64);
-  if (fileSize64 > UINT32_MAX) {
+  hr = stream->GetFileSize(&fileSize64);
+  if (FAILED(hr) || fileSize64 > UINT32_MAX) {
     MOZ_ASSERT(false);
     return false;
   }
 
   uint32_t fileSize = static_cast<uint32_t>(fileSize64);
   const void* fragmentStart;
   void* context;
-  stream->ReadFileFragment(&fragmentStart, 0, fileSize, &context);
+  hr = stream->ReadFileFragment(&fragmentStart, 0, fileSize, &context);
+  if (FAILED(hr)) {
+    return false;
+  }
 
   aDataCallback((uint8_t*)fragmentStart, fileSize, mFontFace->GetIndex(),
                 aBaton);
 
   stream->ReleaseFileFragment(context);
 
   return true;
 }