Bug 514033 - Error recovery for imagelib - part 13 - Stop checking IsError() in decoder implementations.r=joe,a=blocker

This commit is contained in:
Bobby Holley 2010-09-12 08:22:31 -07:00
parent d9a7098dd2
commit 2def2be9ee
6 changed files with 19 additions and 19 deletions

View File

@ -83,11 +83,14 @@ nsBMPDecoder::~nsBMPDecoder()
void
nsBMPDecoder::FinishInternal()
{
// We shouldn't be called in error cases
NS_ABORT_IF_FALSE(!IsError(), "Can't call FinishInternal on error!");
// We should never make multiple frames
NS_ABORT_IF_FALSE(GetFrameCount() <= 1, "Multiple BMP frames?");
// Send notifications if appropriate
if (!IsSizeDecode() && !IsError() && (GetFrameCount() == 1)) {
if (!IsSizeDecode() && (GetFrameCount() == 1)) {
PostFrameStop();
PostDecodeDone();
}
@ -136,9 +139,7 @@ NS_METHOD nsBMPDecoder::CalcBitShift()
void
nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
{
// No forgiveness
if (IsError())
return;
NS_ABORT_IF_FALSE(!IsError(), "Shouldn't call WriteInternal after error!");
// aCount=0 means EOF, mCurLine=0 means we're past end of image
if (!aCount || !mCurLine)

View File

@ -134,8 +134,10 @@ nsGIFDecoder2::~nsGIFDecoder2()
void
nsGIFDecoder2::FinishInternal()
{
NS_ABORT_IF_FALSE(!IsError(), "Shouldn't call FinishInternal after error!");
// If the GIF got cut off, handle it anyway
if (!IsSizeDecode() && !IsError() && mGIFOpen) {
if (!IsSizeDecode() && mGIFOpen) {
if (mCurrentFrame == mGIFStruct.images_decoded)
EndImageFrame();
PostDecodeDone();
@ -604,9 +606,7 @@ static void ConvertColormap(PRUint32 *aColormap, PRUint32 aColors)
void
nsGIFDecoder2::WriteInternal(const char *aBuffer, PRUint32 aCount)
{
// Don't forgive previously flagged errors
if (IsError())
return;
NS_ABORT_IF_FALSE(!IsError(), "Shouldn't call WriteInternal after error!");
// These variables changed names, and renaming would make a much bigger patch :(
const PRUint8 *buf = (const PRUint8 *)aBuffer;

View File

@ -103,11 +103,14 @@ nsICODecoder::~nsICODecoder()
void
nsICODecoder::FinishInternal()
{
// We shouldn't be called in error cases
NS_ABORT_IF_FALSE(!IsError(), "Shouldn't call FinishInternal after error!");
// We should never make multiple frames
NS_ABORT_IF_FALSE(GetFrameCount() <= 1, "Multiple ICO frames?");
// Send notifications if appropriate
if (!IsSizeDecode() && !IsError() && (GetFrameCount() == 1)) {
if (!IsSizeDecode() && (GetFrameCount() == 1)) {
// Invalidate
nsIntRect r(0, 0, mDirEntry.mWidth, mDirEntry.mHeight);
@ -121,9 +124,7 @@ nsICODecoder::FinishInternal()
void
nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
{
// No forgiveness
if (IsError())
return;
NS_ABORT_IF_FALSE(!IsError(), "Shouldn't call WriteInternal after error!");
if (!aCount) // aCount=0 means EOF
return;

View File

@ -67,14 +67,12 @@ nsIconDecoder::~nsIconDecoder()
void
nsIconDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount)
{
nsresult rv;
if (IsError())
return;
NS_ABORT_IF_FALSE(!IsError(), "Shouldn't call WriteInternal after error!");
// We put this here to avoid errors about crossing initialization with case
// jumps on linux.
PRUint32 bytesToRead = 0;
nsresult rv;
// Performance isn't critical here, so our update rectangle is
// always the full icon

View File

@ -194,6 +194,8 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount)
mSegment = (const JOCTET *)aBuffer;
mSegmentLen = aCount;
NS_ABORT_IF_FALSE(!IsError(), "Shouldn't call WriteInternal after error!");
/* Return here if there is a fatal error within libjpeg. */
nsresult error_code;
if ((error_code = setjmp(mErr.setjmp_buffer)) != 0) {

View File

@ -295,9 +295,7 @@ nsPNGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount)
PRUint32 width = 0;
PRUint32 height = 0;
// No forgiveness if we previously hit an error
if (IsError())
return;
NS_ABORT_IF_FALSE(!IsError(), "Shouldn't call WriteInternal after error!");
// If we only want width/height, we don't need to go through libpng
if (IsSizeDecode()) {