Fix venkman-induced GC-hazard crash bug: keep the nsIXPConnectJSObjectHolder for scriptObject alive across the entire extent of the scriptObject variable (171949, r=peterv, sr=bryner).

git-svn-id: svn://10.0.0.236/trunk@146929 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
brendan%mozilla.org
2003-09-15 21:57:31 +00:00
parent 28e76afd68
commit 4e9ab57fc4

View File

@@ -403,6 +403,10 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventReceiver* aReceiver,
JSObject* scriptObject = nsnull;
// strong ref to a GC root we'll need to protect scriptObject in the case
// where it is not the global object (!winRoot).
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
if (winRoot) {
scriptObject = boundGlobal->GetGlobalJSObject();
} else {
@@ -411,9 +415,6 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventReceiver* aReceiver,
nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID(), &rv));
// root
nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
// XXX: Don't use the global object!
rv = xpc->WrapNative(cx, global, aReceiver, NS_GET_IID(nsISupports),
getter_AddRefs(wrapper));