From cd59845c2517b7ba2cfd3a643d0dbe515cf6513b Mon Sep 17 00:00:00 2001 From: "norris%netscape.com" Date: Wed, 6 Oct 1999 21:12:21 +0000 Subject: [PATCH] Fix 15618 [CRASH] JS assertion on table regression test Reviewed by rogerl@netscape.com. git-svn-id: svn://10.0.0.236/trunk@50020 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/caps/src/nsCodebasePrincipal.cpp | 8 +++++++- mozilla/caps/src/nsJSPrincipals.cpp | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mozilla/caps/src/nsCodebasePrincipal.cpp b/mozilla/caps/src/nsCodebasePrincipal.cpp index 74d49a875b7..195aa7814ca 100644 --- a/mozilla/caps/src/nsCodebasePrincipal.cpp +++ b/mozilla/caps/src/nsCodebasePrincipal.cpp @@ -46,7 +46,13 @@ nsCodebasePrincipal::Release(void) NS_PRECONDITION(0 != mJSPrincipals.refcount, "dup release"); --mJSPrincipals.refcount; NS_LOG_RELEASE(this, mJSPrincipals.refcount, "nsCodebasePrincipal"); - if (mJSPrincipals.refcount == 0) { + if (mJSPrincipals.refcount == 0) { +#ifdef DEBUG_norris + char *spec; + mURI->GetSpec(&spec); + fprintf(stderr, "Releasing principal for %s\n", spec); + delete spec; +#endif NS_DELETEXPCOM(this); return 0; } diff --git a/mozilla/caps/src/nsJSPrincipals.cpp b/mozilla/caps/src/nsJSPrincipals.cpp index 5f99b7cb8d9..81e0c21e5eb 100644 --- a/mozilla/caps/src/nsJSPrincipals.cpp +++ b/mozilla/caps/src/nsJSPrincipals.cpp @@ -35,6 +35,9 @@ nsGlobalPrivilegesEnabled(JSContext *cx , struct JSPrincipals *jsprin) PR_STATIC_CALLBACK(void) nsDestroyJSPrincipals(JSContext *cx, struct JSPrincipals *jsprin) { nsJSPrincipals *nsjsprin = (nsJSPrincipals *)jsprin; + // We need to destroy the nsIPrincipal. We'll do this by adding + // to the refcount and calling release + nsjsprin->refcount++; NS_IF_RELEASE(nsjsprin->nsIPrincipalPtr); // The nsIPrincipal that we release owns the JSPrincipal struct, // so we don't need to worry about "codebase"