Bug 462728 crash when using alert from docloaderservice onStateChange listener [@ nsJARChannel::OnStartRequest]

r=biesi
This commit is contained in:
timeless 2009-03-05 13:27:48 +01:00
parent 2db3d81751
commit 53c762b512

View File

@ -694,21 +694,30 @@ nsJARChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx)
nsresult rv = EnsureJarInput(PR_FALSE);
if (NS_FAILED(rv)) return rv;
// These variables must only be set if we're going to trigger an
// OnStartRequest, either from AsyncRead or OnDownloadComplete.
mListener = listener;
mListenerContext = ctx;
mIsPending = PR_TRUE;
if (mJarInput) {
// create input stream pump
// create input stream pump and call AsyncRead as a block
rv = NS_NewInputStreamPump(getter_AddRefs(mPump), mJarInput);
if (NS_FAILED(rv)) return rv;
if (NS_SUCCEEDED(rv))
rv = mPump->AsyncRead(this, nsnull);
rv = mPump->AsyncRead(this, nsnull);
if (NS_FAILED(rv)) return rv;
// If we failed to create the pump or initiate the AsyncRead,
// then we need to clear these variables.
if (NS_FAILED(rv)) {
mIsPending = PR_FALSE;
mListenerContext = nsnull;
mListener = nsnull;
return rv;
}
}
if (mLoadGroup)
mLoadGroup->AddRequest(this, nsnull);
mListener = listener;
mListenerContext = ctx;
mIsPending = PR_TRUE;
return NS_OK;
}