From 741e9f0d95936f836126ccc1a42a38a73136d7ee Mon Sep 17 00:00:00 2001 From: "timeless%mozdev.org" Date: Tue, 19 Jul 2005 21:55:36 +0000 Subject: [PATCH] Bug 300853 Caps crash on cleanup [@ DomainPolicy::Drop] patch by g.maone@informaction.com r=caillon sr=dveditz a=bsmedberg --- caps/include/nsPrincipal.h | 1 + caps/include/nsScriptSecurityManager.h | 5 ++++- caps/src/nsPrincipal.cpp | 1 + caps/src/nsScriptSecurityManager.cpp | 8 ++++++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/caps/include/nsPrincipal.h b/caps/include/nsPrincipal.h index 5f0375bdc17..dafce92b782 100755 --- a/caps/include/nsPrincipal.h +++ b/caps/include/nsPrincipal.h @@ -21,6 +21,7 @@ * * Contributor(s): * Christopher A. Aillon + * Giorgio Maone * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/caps/include/nsScriptSecurityManager.h b/caps/include/nsScriptSecurityManager.h index e110b09409a..b32503df2b0 100644 --- a/caps/include/nsScriptSecurityManager.h +++ b/caps/include/nsScriptSecurityManager.h @@ -23,6 +23,7 @@ * Norris Boyd * Mitch Stoltz * Christopher A. Aillon + * Giorgio Maone * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -79,6 +80,7 @@ struct ClassPolicy; #define DEBUG_CAPS_CanCreateWrapper #define DEBUG_CAPS_CanCreateInstance #define DEBUG_CAPS_CanGetService +#define DEBUG_CAPS_DomainPolicyLifeCycle #endif ///////////////////// @@ -290,8 +292,9 @@ public: ~DomainPolicy() { PL_DHashTableFinish(this); - + NS_ASSERTION(mRefCount == 0, "Wrong refcount in DomainPolicy dtor"); #ifdef DEBUG_CAPS_DomainPolicyLifeCycle + printf("DomainPolicy deleted with mRefCount = %d\n", mRefCount); --sObjects; _printPopulationInfo(); #endif diff --git a/caps/src/nsPrincipal.cpp b/caps/src/nsPrincipal.cpp index 12129b78fd3..063982f805c 100755 --- a/caps/src/nsPrincipal.cpp +++ b/caps/src/nsPrincipal.cpp @@ -21,6 +21,7 @@ * * Contributor(s): * Christopher A. Aillon + * Giorgio Maone * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/caps/src/nsScriptSecurityManager.cpp b/caps/src/nsScriptSecurityManager.cpp index bb770d2f4a5..e694cb75915 100644 --- a/caps/src/nsScriptSecurityManager.cpp +++ b/caps/src/nsScriptSecurityManager.cpp @@ -24,6 +24,7 @@ * Mitch Stoltz * Steve Morse * Christopher A. Aillon + * Giorgio Maone * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -2891,7 +2892,8 @@ jsval nsScriptSecurityManager::sEnabledID = JSVAL_VOID; nsScriptSecurityManager::~nsScriptSecurityManager(void) { delete mOriginToPolicyMap; - delete mDefaultPolicy; + if(mDefaultPolicy) + mDefaultPolicy->Drop(); delete mCapabilities; gScriptSecMan = nsnull; } @@ -2980,8 +2982,10 @@ nsScriptSecurityManager::InitPolicies() DomainPolicy::InvalidateAll(); //-- Release old default policy - if(mDefaultPolicy) + if(mDefaultPolicy) { mDefaultPolicy->Drop(); + mDefaultPolicy = nsnull; + } //-- Initialize a new mOriginToPolicyMap mOriginToPolicyMap =