Bug 723446. Be a little more careful changing declarations on keyframe rules. r=dbaron, a=akeybl
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 02 Feb 2012 11:59:39 -0500
changeset 88332 68fb495e3183754b2692f438dbe664a1c48cbea9
parent 88331 1f3329e303fe0676950a1430467427361e4fbb5a
child 88333 10b4c33374b7b85d1f276b3eb9e9fc0fe2c525ec
push idunknown
push userunknown
push dateunknown
reviewersdbaron, akeybl
bugs723446
milestone12.0a2
Bug 723446. Be a little more careful changing declarations on keyframe rules. r=dbaron, a=akeybl
layout/style/nsCSSRules.cpp
xpcom/base/nsAutoPtr.h
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -1870,17 +1870,21 @@ nsCSSKeyframeRule::GetStyle(nsIDOMCSSSty
   }
   NS_ADDREF(*aStyle = mDOMDeclaration);
   return NS_OK;
 }
 
 void
 nsCSSKeyframeRule::ChangeDeclaration(css::Declaration* aDeclaration)
 {
-  mDeclaration = aDeclaration;
+  // Be careful to not assign to an nsAutoPtr if we would be assigning
+  // the thing it already holds.
+  if (aDeclaration != mDeclaration) {
+    mDeclaration = aDeclaration;
+  }
 
   if (mSheet) {
     mSheet->SetModifiedByChildRule();
   }
 }
 
 // -------------------------------------------
 // nsCSSKeyframesRule
--- a/xpcom/base/nsAutoPtr.h
+++ b/xpcom/base/nsAutoPtr.h
@@ -61,16 +61,17 @@ class nsAutoPtr
         {
           assign(0);
           return reinterpret_cast<void**>(&mRawPtr);
         }
 
       void
       assign( T* newPtr )
         {
+          NS_ABORT_IF_FALSE(mRawPtr != newPtr || !newPtr, "This makes no sense!");
           T* oldPtr = mRawPtr;
           mRawPtr = newPtr;
           delete oldPtr;
         }
 
       // |class Ptr| helps us prevent implicit "copy construction"
       // through |operator T*() const| from a |const nsAutoPtr<T>|
       // because two implicit conversions in a row aren't allowed.