Bug 483788. Don't leak if a broken protocol handler returns a channel but error rv. r=bsmedberg, moa=biesi

This commit is contained in:
Boris Zbarsky 2009-03-23 14:53:14 -04:00
parent e29d8ab4e4
commit 30a3d1ae6c

View File

@ -177,8 +177,8 @@ NS_NewChannel(nsIChannel **result,
nsCOMPtr<nsIIOService> grip;
rv = net_EnsureIOService(&ioService, grip);
if (ioService) {
nsIChannel *chan;
rv = ioService->NewChannelFromURI(uri, &chan);
nsCOMPtr<nsIChannel> chan;
rv = ioService->NewChannelFromURI(uri, getter_AddRefs(chan));
if (NS_SUCCEEDED(rv)) {
if (loadGroup)
rv |= chan->SetLoadGroup(loadGroup);
@ -187,9 +187,7 @@ NS_NewChannel(nsIChannel **result,
if (loadFlags != nsIRequest::LOAD_NORMAL)
rv |= chan->SetLoadFlags(loadFlags);
if (NS_SUCCEEDED(rv))
*result = chan;
else
NS_RELEASE(chan);
chan.forget(result);
}
}
return rv;