Bug 1251848: Check StyleSheetHandles for being null-flavored before derefing them, in assertions within nsLayoutStylesheetCache::InvalidateSheet. r=bholley
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 29 Feb 2016 18:57:05 -0800
changeset 324435 87ea50b0a2603d94b38276891684cba2b9e5df12
parent 324434 fd9990a554a2120bb0f9fe59f575562a808323c4
child 324436 0c59c0fc07fb5e182ca9ec52653c90fd85452cd9
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1251848
milestone47.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 1251848: Check StyleSheetHandles for being null-flavored before derefing them, in assertions within nsLayoutStylesheetCache::InvalidateSheet. r=bholley
layout/style/nsLayoutStylesheetCache.cpp
--- a/layout/style/nsLayoutStylesheetCache.cpp
+++ b/layout/style/nsLayoutStylesheetCache.cpp
@@ -763,43 +763,46 @@ nsLayoutStylesheetCache::LoadSheet(nsIUR
 
 /* static */ void
 nsLayoutStylesheetCache::InvalidateSheet(StyleSheetHandle::RefPtr* aGeckoSheet,
                                          StyleSheetHandle::RefPtr* aServoSheet)
 {
   MOZ_ASSERT(gCSSLoader_Gecko || gCSSLoader_Servo,
              "pref changed before we loaded a sheet?");
 
+  const bool gotGeckoSheet = aGeckoSheet && *aGeckoSheet;
+  const bool gotServoSheet = aServoSheet && *aServoSheet;
+
   // Make sure sheets have the expected types
-  MOZ_ASSERT(!aGeckoSheet || (*aGeckoSheet)->IsGecko());
-  MOZ_ASSERT(!aServoSheet || (*aServoSheet)->IsServo());
+  MOZ_ASSERT(!gotGeckoSheet || (*aGeckoSheet)->IsGecko());
+  MOZ_ASSERT(!gotServoSheet || (*aServoSheet)->IsServo());
   // Make sure the URIs match
-  MOZ_ASSERT(!aGeckoSheet || !aServoSheet ||
+  MOZ_ASSERT(!gotServoSheet || !gotGeckoSheet ||
              (*aGeckoSheet)->GetSheetURI() == (*aServoSheet)->GetSheetURI(),
              "Sheets passed should have the same URI");
 
   nsIURI* uri;
-  if (aGeckoSheet && *aGeckoSheet) {
+  if (gotGeckoSheet) {
     uri = (*aGeckoSheet)->GetSheetURI();
-  } else if (aServoSheet && *aServoSheet) {
+  } else if (gotServoSheet) {
     uri = (*aServoSheet)->GetSheetURI();
   } else {
     return;
   }
 
   if (gCSSLoader_Gecko) {
     gCSSLoader_Gecko->ObsoleteSheet(uri);
   }
   if (gCSSLoader_Servo) {
     gCSSLoader_Servo->ObsoleteSheet(uri);
   }
-  if (aGeckoSheet) {
+  if (gotGeckoSheet) {
     *aGeckoSheet = nullptr;
   }
-  if (aServoSheet) {
+  if (gotServoSheet) {
     *aServoSheet = nullptr;
   }
 }
 
 /* static */ void
 nsLayoutStylesheetCache::DependentPrefChanged(const char* aPref, void* aData)
 {
   MOZ_ASSERT(gStyleCache_Gecko || gStyleCache_Servo,