Bug 524921. Patch by Joe Drew <joe@drew.ca>, r=jrmuizel sr=vlad, a1.9.0.next=dveditz

git-svn-id: svn://10.0.0.236/trunk@260867 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
alqahira%ardisson.org 2010-07-23 19:09:43 +00:00
parent a555a1d8c9
commit 4c13fb02c6
2 changed files with 21 additions and 11 deletions

View File

@ -192,12 +192,17 @@ NS_IMETHODIMP nsJPEGDecoder::Init(imgILoad *aLoad)
return NS_ERROR_OUT_OF_MEMORY;
mImageLoad->SetImage(mImage);
nsresult result = mImage->SetDiscardable("image/jpeg");
if (NS_FAILED(result)) {
mState = JPEG_ERROR;
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
(" (could not set image container to discardable)"));
return result;
// Don't discard if we're multipart, and assume we are for safety.
PRBool multipart = PR_TRUE;
if (NS_SUCCEEDED(mImageLoad->GetIsMultiPartChannel(&multipart)) && !multipart) {
nsresult result = mImage->SetDiscardable("image/jpeg");
if (NS_FAILED(result)) {
mState = JPEG_ERROR;
PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG,
(" (could not set image container to discardable)"));
return result;
}
}
}

View File

@ -302,11 +302,16 @@ NS_IMETHODIMP nsPNGDecoder::Init(imgILoad *aLoad)
return NS_ERROR_OUT_OF_MEMORY;
mImageLoad->SetImage(mImage);
if (NS_FAILED(mImage->SetDiscardable("image/png"))) {
PR_LOG(gPNGDecoderAccountingLog, PR_LOG_DEBUG,
("PNGDecoderAccounting: info_callback(): failed to set image container %p as discardable",
mImage.get()));
return NS_ERROR_FAILURE;
// Don't discard if we're multipart, and assume we are for safety.
PRBool multipart = PR_TRUE;
if (NS_SUCCEEDED(mImageLoad->GetIsMultiPartChannel(&multipart)) && !multipart) {
if (NS_FAILED(mImage->SetDiscardable("image/png"))) {
PR_LOG(gPNGDecoderAccountingLog, PR_LOG_DEBUG,
("PNGDecoderAccounting: info_callback(): failed to set image container %p as discardable",
mImage.get()));
return NS_ERROR_FAILURE;
}
}
}