diff --git a/mozilla/content/html/style/src/nsCSSStyleRule.cpp b/mozilla/content/html/style/src/nsCSSStyleRule.cpp
index b428220ca60..bd84ad82f19 100644
--- a/mozilla/content/html/style/src/nsCSSStyleRule.cpp
+++ b/mozilla/content/html/style/src/nsCSSStyleRule.cpp
@@ -985,6 +985,8 @@ DOMCSSDeclarationImpl::DeclarationChanged()
nsCOMPtr oldRule = mRule;
mRule = oldRule->DeclarationChanged(PR_TRUE).get();
+ if (!mRule)
+ return NS_ERROR_OUT_OF_MEMORY;
nsrefcnt cnt = mRule->Release();
NS_ASSERTION(cnt != 0, "container didn't take ownership");
diff --git a/mozilla/layout/style/nsCSSStyleRule.cpp b/mozilla/layout/style/nsCSSStyleRule.cpp
index b428220ca60..bd84ad82f19 100644
--- a/mozilla/layout/style/nsCSSStyleRule.cpp
+++ b/mozilla/layout/style/nsCSSStyleRule.cpp
@@ -985,6 +985,8 @@ DOMCSSDeclarationImpl::DeclarationChanged()
nsCOMPtr oldRule = mRule;
mRule = oldRule->DeclarationChanged(PR_TRUE).get();
+ if (!mRule)
+ return NS_ERROR_OUT_OF_MEMORY;
nsrefcnt cnt = mRule->Release();
NS_ASSERTION(cnt != 0, "container didn't take ownership");