Bug 609499 - Some invalid GIF files don't terminate their LZW data with a 0-length block. Handle them better by handling them less specially. r=jrmuizel
authorJoe Drew <joe@drew.ca>
Wed, 03 Aug 2011 15:19:19 -0400
changeset 73772 67044ea27b5380220a66893b1cb54ae89ea18dab
parent 73771 cfb447e2f21f66a061e95645d143ebf3865a45ee
child 73773 b38381eb91b8cbedb4f0d13963399944f9b07bcf
push id947
push userjdrew@mozilla.com
push dateWed, 03 Aug 2011 19:23:29 +0000
treeherdermozilla-inbound@20c37bc31102 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs609499
milestone8.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 609499 - Some invalid GIF files don't terminate their LZW data with a 0-length block. Handle them better by handling them less specially. r=jrmuizel
modules/libpr0n/decoders/nsGIFDecoder2.cpp
--- a/modules/libpr0n/decoders/nsGIFDecoder2.cpp
+++ b/modules/libpr0n/decoders/nsGIFDecoder2.cpp
@@ -1022,37 +1022,24 @@ nsGIFDecoder2::WriteInternal(const char 
       // Everything is already copied into local_colormap
       // Convert into Cairo colors including CMS transformation
       ConvertColormap(mColormap, mGIFStruct.local_colormap_size);
       GETN(1, gif_lzw_start);
       break;
 
     case gif_sub_block:
       mGIFStruct.count = *q;
-      if (mGIFStruct.count) {
-        /* Still working on the same image: Process next LZW data block */
-        /* Make sure there are still rows left. If the GIF data */
-        /* is corrupt, we may not get an explicit terminator.   */
-        if (!mGIFStruct.rows_remaining) {
-#ifdef DONT_TOLERATE_BROKEN_GIFS
-          mGIFStruct.state = gif_error;
-          break;
-#else
-          /* This is an illegal GIF, but we remain tolerant. */
-          GETN(1, gif_sub_block);
-#endif
-          if (mGIFStruct.count == GIF_TRAILER) {
-            /* Found a terminator anyway, so consider the image done */
-            GETN(1, gif_done);
-            break;
-          }
-        }
+      // We can have multiple LZW data blocks. Process the next, but only if
+      // there are any rows left. (If the GIF is invalid, we might not get an
+      // explicit 0-size block terminator.)
+      if (mGIFStruct.count && mGIFStruct.rows_remaining) {
         GETN(mGIFStruct.count, gif_lzw);
       } else {
-        /* See if there are any more images in this sequence. */
+        // We've finished decoding this image. See if there are any more images
+        // in this sequence.
         EndImageFrame();
         GETN(1, gif_image_start);
       }
       break;
 
     case gif_done:
       PostDecodeDone();
       mGIFOpen = PR_FALSE;