From 47cd835bdd2a0c71d38ff31e710bc4a1cb0b1dfd Mon Sep 17 00:00:00 2001 From: "rpotts%netscape.com" Date: Wed, 11 Nov 1998 10:04:57 +0000 Subject: [PATCH] Fixed random crash... git-svn-id: svn://10.0.0.236/trunk@14422 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gfx/src/nsImageNetContextAsync.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/mozilla/gfx/src/nsImageNetContextAsync.cpp b/mozilla/gfx/src/nsImageNetContextAsync.cpp index ce43ed101a3..b95bf031b24 100644 --- a/mozilla/gfx/src/nsImageNetContextAsync.cpp +++ b/mozilla/gfx/src/nsImageNetContextAsync.cpp @@ -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);