Commit 16420888 authored by dp%netscape.com's avatar dp%netscape.com
Browse files

bug#16742 Fixing delete on nsISupports. Thanks for patch from

<heikki@citec.fi> r=dp
parent 038812ce
......@@ -637,10 +637,10 @@ CreateJSComponentLoader(nsISupports *aOuter, const nsIID &iid, void **result)
return NS_ERROR_NULL_POINTER;
*result = 0;
nsISupports *inst = 0;
mozJSComponentLoader *inst;
if (iid.Equals(NS_GET_IID(nsIComponentLoader))) {
inst = (nsISupports *)new mozJSComponentLoader();
inst = new mozJSComponentLoader();
} else {
return NS_ERROR_NO_INTERFACE;
}
......@@ -648,10 +648,12 @@ CreateJSComponentLoader(nsISupports *aOuter, const nsIID &iid, void **result)
if (!inst)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(inst); // Stabilize
nsresult rv = inst->QueryInterface(iid, result);
if (NS_FAILED(rv)) {
delete inst;
}
NS_RELEASE(inst); // Destabilize and avoid leaks. Avoid calling delete <interface pointer>
return rv;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment