Bug 395585 - OOM problems in nsPNGEncoder.cpp - r=bbondy
authorBenoit Jacob <bjacob@mozilla.com>
Thu, 13 Oct 2011 08:09:22 -0400
changeset 78691 b79549daab38f0087f9de9509e7b8ba309d5cbce
parent 78690 ed8aa9cecb82bd9a9e68bd601fabbb480cd73e86
child 78692 7170a4b7a58d039d799e88deb596fcb4b44c18b2
push id21326
push userbmo@edmorley.co.uk
push dateFri, 14 Oct 2011 10:00:06 +0000
treeherdermozilla-central@ca73f057dab7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy
bugs395585
milestone10.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 395585 - OOM problems in nsPNGEncoder.cpp - r=bbondy
modules/libpr0n/encoders/png/nsPNGEncoder.cpp
--- a/modules/libpr0n/encoders/png/nsPNGEncoder.cpp
+++ b/modules/libpr0n/encoders/png/nsPNGEncoder.cpp
@@ -696,16 +696,17 @@ nsPNGEncoder::WriteCallback(png_structp 
 
     // expand buffer, just double each time
     that->mImageBufferSize *= 2;
     PRUint8* newBuf = (PRUint8*)PR_Realloc(that->mImageBuffer,
                                            that->mImageBufferSize);
     if (! newBuf) {
       // can't resize, just zero (this will keep us from writing more)
       PR_Free(that->mImageBuffer);
+      that->mImageBuffer = nsnull;
       that->mImageBufferSize = 0;
       that->mImageBufferUsed = 0;
       return;
     }
     that->mImageBuffer = newBuf;
   }
   memcpy(&that->mImageBuffer[that->mImageBufferUsed], data, size);
   that->mImageBufferUsed += size;