Bug 1435139 - Don't call into RemovePropertyInternal from RemoveProperty when the property doesn't exist. r?bz draft
authorXidorn Quan <me@upsuper.org>
Fri, 02 Feb 2018 14:24:53 +1100
changeset 750417 b238cf8e3a472e70b34aa8b49da03e65001a3a56
parent 750416 85429c4275971481f67e1c70e78f7f69b6384168
push id97649
push userxquan@mozilla.com
push dateFri, 02 Feb 2018 03:27:46 +0000
reviewersbz
bugs1435139
milestone60.0a1
Bug 1435139 - Don't call into RemovePropertyInternal from RemoveProperty when the property doesn't exist. r?bz MozReview-Commit-ID: 4pDCtiLIORn
layout/style/nsDOMCSSDeclaration.cpp
--- a/layout/style/nsDOMCSSDeclaration.cpp
+++ b/layout/style/nsDOMCSSDeclaration.cpp
@@ -249,16 +249,20 @@ nsDOMCSSDeclaration::SetProperty(const n
 }
 
 NS_IMETHODIMP
 nsDOMCSSDeclaration::RemoveProperty(const nsAString& aPropertyName,
                                     nsAString& aReturn)
 {
   nsresult rv = GetPropertyValue(aPropertyName, aReturn);
   NS_ENSURE_SUCCESS(rv, rv);
+  // If the property doesn't exist, it makes no sense to go further.
+  if (aReturn.IsEmpty()) {
+    return NS_OK;
+  }
   return RemovePropertyInternal(aPropertyName);
 }
 
 /* static */ void
 nsDOMCSSDeclaration::GetCSSParsingEnvironmentForRule(css::Rule* aRule,
                                                      CSSParsingEnvironment& aCSSParseEnv)
 {
   StyleSheet* sheet = aRule ? aRule->GetStyleSheet() : nullptr;