Bug 1357716 - stylo: Don't return uninitialized pointers from GetCSSStyleRules. r=xidorn
authorMatt Brubeck <mbrubeck@mozilla.com>
Thu, 18 May 2017 14:50:05 -0700
changeset 359062 2afa6edea6d02da4aad582605481b2c96853ce7d
parent 359061 f627cd94f91f281a33fe4e6027d06e3766f7a81b
child 359063 10c052ccf90c8d271015b392dc0d81c763516e33
push id42958
push usermbrubeck@mozilla.com
push dateThu, 18 May 2017 22:44:53 +0000
treeherderautoland@2afa6edea6d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1357716
milestone55.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 1357716 - stylo: Don't return uninitialized pointers from GetCSSStyleRules. r=xidorn MozReview-Commit-ID: JPj6d27PALc
layout/inspector/inDOMUtils.cpp
--- a/layout/inspector/inDOMUtils.cpp
+++ b/layout/inspector/inDOMUtils.cpp
@@ -294,21 +294,25 @@ inDOMUtils::GetCSSStyleRules(nsIDOMEleme
         // Generate the map from raw rules to rules.
         ruleList->FillStyleRuleHashtable(rawRulesToRules);
       }
     }
 
     // Find matching rules in the table.
     for (size_t j = 0; j < rawRuleCount; j++) {
       const RawServoStyleRule* rawRule = rawRuleList.ElementAt(j);
-      ServoStyleRule* rule;
-      rawRulesToRules.Get(rawRule, &rule);
-      MOZ_ASSERT(rule, "We should always be able to map a raw rule to a rule.");
-      RefPtr<css::Rule> ruleObj(rule);
-      rules->AppendElement(ruleObj, false);
+      ServoStyleRule* rule = nullptr;
+      if (rawRulesToRules.Get(rawRule, &rule)) {
+        MOZ_ASSERT(rule, "rule should not be null");
+        RefPtr<css::Rule> ruleObj(rule);
+        rules->AppendElement(ruleObj, false);
+      } else {
+        // FIXME (bug 1359217): Need a reliable way to map raw rules to rules.
+        NS_WARNING("stylo: Could not map raw rule to a rule.");
+      }
     }
   }
 
   rules.forget(_retval);
 
   return NS_OK;
 }