From ad5fde345ecfb403ac672645777afcb1d2487a84 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 2 Feb 2012 11:59:39 -0500 Subject: [PATCH] Bug 723446. Be a little more careful changing declarations on keyframe rules. r=dbaron --- layout/style/nsCSSRules.cpp | 6 +++++- xpcom/base/nsAutoPtr.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index 49a0c26862d..6dbd76fe84d 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -1964,7 +1964,11 @@ nsCSSKeyframeRule::GetStyle(nsIDOMCSSStyleDeclaration** aStyle) 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(); diff --git a/xpcom/base/nsAutoPtr.h b/xpcom/base/nsAutoPtr.h index a32bd263523..02dbbb1f595 100644 --- a/xpcom/base/nsAutoPtr.h +++ b/xpcom/base/nsAutoPtr.h @@ -66,6 +66,7 @@ class nsAutoPtr void assign( T* newPtr ) { + NS_ABORT_IF_FALSE(mRawPtr != newPtr || !newPtr, "This makes no sense!"); T* oldPtr = mRawPtr; mRawPtr = newPtr; delete oldPtr;