Bug 1321522: Add null check and logging on fontResource in RecordedScaledFontCreation::PlayEvent. r=milan a=gchang
authorBob Owen <bobowencode@gmail.com>
Thu, 15 Dec 2016 10:55:10 +0000
changeset 452610 ffbf2dcc32bbbb54b2dde926f2feca070f330a49
parent 452609 5e4495f87ea2d1f0e3a3d33e3fd4c82c2fb6dd8d
child 452611 83e4a4618cbb25a15a9b27a14f67a498dcf3aba2
push id39418
push userbmo:twointofive@gmail.com
push dateWed, 21 Dec 2016 20:59:30 +0000
reviewersmilan, gchang
bugs1321522
milestone51.0
Bug 1321522: Add null check and logging on fontResource in RecordedScaledFontCreation::PlayEvent. r=milan a=gchang MozReview-Commit-ID: 3nM28xgGLPO
gfx/2d/Logging.h
gfx/2d/RecordedEvent.cpp
--- a/gfx/2d/Logging.h
+++ b/gfx/2d/Logging.h
@@ -124,16 +124,17 @@ enum class LogReason : int {
   InvalidContext,
   InvalidCommandList,
   AsyncTransactionTimeout, // 30
   TextureCreation,
   InvalidCacheSurface,
   AlphaWithBasicClient,
   UnbalancedClipStack,
   ProcessingError,
+  NativeFontResourceNotFound,
   // End
   MustBeLessThanThis = 101,
 };
 
 struct BasicLogger
 {
   // For efficiency, this method exists and copies the logic of the
   // OutputMessage below.  If making any changes here, also make it
--- a/gfx/2d/RecordedEvent.cpp
+++ b/gfx/2d/RecordedEvent.cpp
@@ -1639,16 +1639,22 @@ RecordedFontDescriptor::RecordedFontDesc
   mData.resize(size);
   aStream.read((char*)&mData[0], size);
 }
 
 bool
 RecordedScaledFontCreation::PlayEvent(Translator *aTranslator) const
 {
   NativeFontResource *fontResource = aTranslator->LookupNativeFontResource(mFontDataKey);
+  if (!fontResource) {
+    gfxDevCrash(LogReason::NativeFontResourceNotFound) <<
+      "NativeFontResource lookup failed for key |" << hexa(mFontDataKey) << "|.";
+    return false;
+  }
+
   RefPtr<ScaledFont> scaledFont = fontResource->CreateScaledFont(mIndex, mGlyphSize);
   aTranslator->AddScaledFont(mRefPtr, scaledFont);
   return true;
 }
 
 void
 RecordedScaledFontCreation::RecordToStream(std::ostream &aStream) const
 {