Bug 827596 - assert at runtime if we try to assign to a nsAutoPtr which already contains the identical pointer, r=dbaron

This commit is contained in:
Benjamin Smedberg 2013-01-24 11:35:53 -05:00
parent 556583510c
commit e883da27fb

View File

@ -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;
}