diff --git a/gfx/thebes/gfxImageSurface.cpp b/gfx/thebes/gfxImageSurface.cpp index 6158943c649..258f1a8b832 100644 --- a/gfx/thebes/gfxImageSurface.cpp +++ b/gfx/thebes/gfxImageSurface.cpp @@ -98,9 +98,12 @@ gfxImageSurface::gfxImageSurface(const gfxIntSize& size, gfxImageFormat format) // if we have a zero-sized surface, just leave mData nsnull if (mSize.height * mStride > 0) { - mData = (unsigned char *) calloc(mSize.height, mStride); + + // Use the fallible allocator here + mData = (unsigned char *) moz_malloc(mSize.height * mStride); if (!mData) return; + memset(mData, 0, mSize.height * mStride); } mOwnsData = PR_TRUE; diff --git a/modules/libpr0n/src/imgFrame.cpp b/modules/libpr0n/src/imgFrame.cpp index 614bda5f63e..c233a0b9185 100644 --- a/modules/libpr0n/src/imgFrame.cpp +++ b/modules/libpr0n/src/imgFrame.cpp @@ -216,7 +216,8 @@ nsresult imgFrame::Init(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, return NS_ERROR_FAILURE; } - mPalettedImageData = (PRUint8*)PR_MALLOC(PaletteDataLength() + GetImageDataLength()); + // Use the fallible allocator here + mPalettedImageData = (PRUint8*)moz_malloc(PaletteDataLength() + GetImageDataLength()); NS_ENSURE_TRUE(mPalettedImageData, NS_ERROR_OUT_OF_MEMORY); } else { // For Windows, we must create the device surface first (if we're