From 3a7c25ffc5641baa21a9dfaed990924feaf8b170 Mon Sep 17 00:00:00 2001 From: Blake Kaplan Date: Thu, 2 Jul 2009 17:00:20 -0700 Subject: [PATCH] Bug 501577 - Add a missing call to Release in nsXPCWrappedJS::GetNewOrUsed. Also remove a hack needed to get around the missing release. r+sr=peterv --- js/src/xpconnect/src/xpcwrappedjs.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/src/xpconnect/src/xpcwrappedjs.cpp b/js/src/xpconnect/src/xpcwrappedjs.cpp index 10bcaf9a6a59..dfc4f8a4d6b2 100644 --- a/js/src/xpconnect/src/xpcwrappedjs.cpp +++ b/js/src/xpconnect/src/xpcwrappedjs.cpp @@ -307,6 +307,7 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx, nsXPCWrappedJS* wrapper = nsnull; nsXPCWrappedJSClass* clazz = nsnull; XPCJSRuntime* rt = ccx.GetRuntime(); + JSBool release_root = JS_FALSE; map = rt->GetWrappedJSMap(); if(!map) @@ -341,6 +342,7 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx, } } } + if(!root) { // build the root wrapper @@ -374,6 +376,9 @@ nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx, if(!root) goto return_wrapper; + + release_root = JS_TRUE; + { // scoped lock #if DEBUG_xpc_leaks printf("Created nsXPCWrappedJS %p, JSObject is %p\n", @@ -407,6 +412,9 @@ return_wrapper: if(clazz) NS_RELEASE(clazz); + if(release_root) + NS_RELEASE(root); + if(!wrapper) return NS_ERROR_FAILURE;