From aea052db06fe7e1f28d5aedfedc2bf880dbd9818 Mon Sep 17 00:00:00 2001 From: "cbiesinger%web.de" Date: Tue, 7 May 2002 10:30:50 +0000 Subject: [PATCH] bug 130876 patch by lorenzo@colitti.com r=pavlov sr=tor some .gifs don't display git-svn-id: svn://10.0.0.236/trunk@120935 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/modules/libpr0n/decoders/gif/GIF2.cpp | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/mozilla/modules/libpr0n/decoders/gif/GIF2.cpp b/mozilla/modules/libpr0n/decoders/gif/GIF2.cpp index b7be1354e7d..0de2f454f58 100644 --- a/mozilla/modules/libpr0n/decoders/gif/GIF2.cpp +++ b/mozilla/modules/libpr0n/decoders/gif/GIF2.cpp @@ -973,12 +973,30 @@ PRStatus gif_write(gif_struct *gs, const PRUint8 *buf, PRUint32 len) GETN(2,gif_extension); break; } - - if (*q!=',') /* invalid start character */ + + /* If we get anything other than ',' (image separator), '!' + * (extension), or ';' (trailer), there is extraneous data + * between blocks. The GIF87a spec tells us to keep reading + * until we find an image separator, but GIF89a says such + * a file is corrupt. We follow GIF89a and bail out. */ + if (*q!=',') { //ILTRACE(2,("il:gif: bogus start character 0x%02x", // (int)*q)); - gs->state=gif_error; + if (gs->images_decoded > 0) + { + /* The file is corrupt, but one or more images have + * been decoded correctly. In this case, we proceed + * as if the file were correctly terminated and set + * the state to gif_done, so the GIF will display. + */ + gs->state = gif_done; + } + else + { + /* No images decoded, there is nothing to display. */ + gs->state = gif_error; + } break; } else