From 310bcc516caa17388aa58b241c552aac2d1163a5 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 git-svn-id: svn://10.0.0.236/trunk@176283 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/caps/include/nsPrincipal.h | 1 + mozilla/caps/include/nsScriptSecurityManager.h | 5 ++++- mozilla/caps/src/nsPrincipal.cpp | 1 + mozilla/caps/src/nsScriptSecurityManager.cpp | 8 ++++++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mozilla/caps/include/nsPrincipal.h b/mozilla/caps/include/nsPrincipal.h index 5f0375bdc17..dafce92b782 100755 --- a/mozilla/caps/include/nsPrincipal.h +++ b/mozilla/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/mozilla/caps/include/nsScriptSecurityManager.h b/mozilla/caps/include/nsScriptSecurityManager.h index e110b09409a..b32503df2b0 100644 --- a/mozilla/caps/include/nsScriptSecurityManager.h +++ b/mozilla/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/mozilla/caps/src/nsPrincipal.cpp b/mozilla/caps/src/nsPrincipal.cpp index 12129b78fd3..063982f805c 100755 --- a/mozilla/caps/src/nsPrincipal.cpp +++ b/mozilla/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/mozilla/caps/src/nsScriptSecurityManager.cpp b/mozilla/caps/src/nsScriptSecurityManager.cpp index bb770d2f4a5..e694cb75915 100644 --- a/mozilla/caps/src/nsScriptSecurityManager.cpp +++ b/mozilla/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 =