From e883da27fb69d9a9b348ca64dcf5e378665bcebb Mon Sep 17 00:00:00 2001 From: Benjamin Smedberg Date: Thu, 24 Jan 2013 11:35:53 -0500 Subject: [PATCH] Bug 827596 - assert at runtime if we try to assign to a nsAutoPtr which already contains the identical pointer, r=dbaron --- xpcom/base/nsAutoPtr.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xpcom/base/nsAutoPtr.h b/xpcom/base/nsAutoPtr.h index 79408bc0f95f..c349d29a5ef0 100644 --- a/xpcom/base/nsAutoPtr.h +++ b/xpcom/base/nsAutoPtr.h @@ -34,8 +34,12 @@ class nsAutoPtr void assign( T* newPtr ) { - NS_ABORT_IF_FALSE(mRawPtr != newPtr || !newPtr, "This makes no sense!"); T* oldPtr = mRawPtr; + + if (newPtr != nullptr && newPtr == oldPtr) { + NS_RUNTIMEABORT("Logic flaw in the caller"); + } + mRawPtr = newPtr; delete oldPtr; }