Closed Bug 10994 Opened 26 years ago Closed 26 years ago

nsArena crashes if destroyed before Init()

Categories

(Core :: XPCOM, defect, P1)

x86
Linux
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: rginda, Assigned: scc-obsolete)

Details

~nsArena calls PL_FinishArenaPool(&mPool); without checking to see if the pool was initialized. The included patch adds an mInitialized member to the class. I'd guess there is probably a Better Way. Index: nsArena.cpp =================================================================== RCS file: /cvsroot/mozilla/xpcom/ds/nsArena.cpp,v retrieving revision 3.4 diff -u -r3.4 nsArena.cpp --- nsArena.cpp 1999/07/28 08:27:38 3.4 +++ nsArena.cpp 1999/07/31 06:51:07 @@ -20,6 +20,7 @@ #include "nsCRT.h" ArenaImpl::ArenaImpl(void) + : mInitialized(PR_FALSE) { NS_INIT_REFCNT(); nsCRT::memset(&mPool, 0, sizeof(PLArenaPool)); @@ -33,6 +34,7 @@ } PL_INIT_ARENA_POOL(&mPool, "nsIArena", aBlockSize); mBlockSize = aBlockSize; + mInitialized = PR_TRUE; return NS_OK; } @@ -40,7 +42,8 @@ ArenaImpl::~ArenaImpl() { - PL_FinishArenaPool(&mPool); + if (mInitialized) + PL_FinishArenaPool(&mPool); } NS_IMETHODIMP_(void*) Index: nsArena.h =================================================================== RCS file: /cvsroot/mozilla/xpcom/ds/nsArena.h,v retrieving revision 1.2 diff -u -r1.2 nsArena.h --- nsArena.h 1999/07/28 08:27:38 1.2 +++ nsArena.h 1999/07/31 06:51:07 @@ -42,6 +42,10 @@ protected: PLArenaPool mPool; PRUint32 mBlockSize; + +private: + PRBool mInitialized; + }; #endif // nsArena_h__
Assignee: dp → scc
oops... - PL_FinishArenaPool(&mPool); + if (mInitialized) + PL_FinishArenaPool(&mPool); that should be - PL_FinishArenaPool(&mPool); + if (mInitialized) + PL_FinishArenaPool(&mPool); + + mInitialized = PR_FALSE;
Status: NEW → ASSIGNED
Shouldn't this be critical severity, since it crashes?
I thought I fixed this a while back. Maybe it never got checked in. Someone should verify.
Target Milestone: M9
Priority: P3 → P1
this is a crasher, it needs to be a high priority
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.