From 1f14d983888529f16c824815aa08b90bdc70efaf Mon Sep 17 00:00:00 2001 From: "pavlov%pavlov.net" Date: Mon, 15 Oct 2007 22:47:37 +0000 Subject: [PATCH] need null check around mImage incase of an error --- modules/libpr0n/decoders/png/nsPNGDecoder.cpp | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/modules/libpr0n/decoders/png/nsPNGDecoder.cpp b/modules/libpr0n/decoders/png/nsPNGDecoder.cpp index 00dbd349dee..5e46932eb2e 100644 --- a/modules/libpr0n/decoders/png/nsPNGDecoder.cpp +++ b/modules/libpr0n/decoders/png/nsPNGDecoder.cpp @@ -226,20 +226,21 @@ NS_IMETHODIMP nsPNGDecoder::Close() if (mPNG) png_destroy_read_struct(&mPNG, mInfo ? &mInfo : NULL, NULL); - nsresult result = mImage->RestoreDataDone(); - if (NS_FAILED (result)) { + if (mImage) { // mImage could be null in the case of an error + nsresult result = mImage->RestoreDataDone(); + if (NS_FAILED(result)) { + PR_LOG(gPNGDecoderAccountingLog, PR_LOG_DEBUG, + ("PNGDecoderAccounting: nsPNGDecoder::Close(): failure in RestoreDataDone() for image container %p", + mImage.get())); + + mError = PR_TRUE; + return result; + } + PR_LOG(gPNGDecoderAccountingLog, PR_LOG_DEBUG, - ("PNGDecoderAccounting: nsPNGDecoder::Close(): failure in RestoreDataDone() for image container %p", + ("PNGDecoderAccounting: nsPNGDecoder::Close(): image container %p is now with RestoreDataDone", mImage.get())); - - mError = PR_TRUE; - return result; } - - PR_LOG(gPNGDecoderAccountingLog, PR_LOG_DEBUG, - ("PNGDecoderAccounting: nsPNGDecoder::Close(): image container %p is now with RestoreDataDone", - mImage.get())); - return NS_OK; }