Fixed random crash...

git-svn-id: svn://10.0.0.236/trunk@14422 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rpotts%netscape.com
1998-11-11 10:04:57 +00:00
parent f5eeccb6c0
commit 47cd835bdd

View File

@@ -182,12 +182,6 @@ ImageConsumer::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 l
{
PRInt32 max_read;
PRInt32 bytes_read = 0, str_length;
// If we previously held onto a stream, drop our reference
if (mStream != nsnull) {
NS_RELEASE(mStream);
}
ilINetReader *reader = mURL->GetReader();
if (mInterrupted || mStatus != 0) {
@@ -247,8 +241,12 @@ ImageConsumer::OnDataAvailable(nsIURL* aURL, nsIInputStream *pIStream, PRInt32 l
// If we haven't emptied the stream, hold onto it, because
// we will need to read from it subsequently and we don't
// know if we'll get a OnDataAvailable call again.
//
// Addref the new stream before releasing the old one,
// in case it is the same stream!
NS_ADDREF(pIStream);
NS_IF_RELEASE(mStream);
mStream = pIStream;
NS_ADDREF(mStream);
}
NS_RELEASE(reader);