Bug 578357 - Use fallible allocation for image frames.r=joe,cjones;a=blocker

This commit is contained in:
Bobby Holley 2010-08-23 15:42:51 -07:00
parent c8266d2dc1
commit 9b62c35018
2 changed files with 6 additions and 2 deletions

View File

@ -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;

View File

@ -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