]> granicus.if.org Git - libjpeg-turbo/commitdiff
The previous attempt to handle unexpected markers in the data stream caused breakage...
authorDRC <dcommander@users.sourceforge.net>
Sat, 16 Apr 2011 18:53:26 +0000 (18:53 +0000)
committerDRC <dcommander@users.sourceforge.net>
Sat, 16 Apr 2011 18:53:26 +0000 (18:53 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@584 632fc199-4ca6-4c93-a231-07263d6284db

jdhuff.c

index f6b6e0087e06d48260bf45491659b3728e869e7f..b795462f4928632b950af2d772070026bbdaa47b 100644 (file)
--- a/jdhuff.c
+++ b/jdhuff.c
@@ -740,9 +740,9 @@ decode_mcu_fast (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
     }
   }
 
-  if (cinfo->unread_marker != 0 && ! cinfo->entropy->insufficient_data) {
-    WARNMS(cinfo, JWRN_HIT_MARKER);
-    cinfo->entropy->insufficient_data = TRUE;
+  if (cinfo->unread_marker != 0) {
+    cinfo->unread_marker = 0;
+    return FALSE;
   }
 
   br_state.bytes_in_buffer -= (buffer - br_state.next_input_byte);
@@ -784,7 +784,8 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
     usefast = 0;
   }
 
-  if (cinfo->src->bytes_in_buffer < BUFSIZE * cinfo->blocks_in_MCU)
+  if (cinfo->src->bytes_in_buffer < BUFSIZE * cinfo->blocks_in_MCU
+    || cinfo->unread_marker != 0)
     usefast = 0;
 
   /* If we've run out of data, just leave the MCU set to zeroes.
@@ -793,9 +794,10 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
   if (! entropy->pub.insufficient_data) {
 
     if (usefast) {
-      if (!decode_mcu_fast(cinfo, MCU_data)) return FALSE;
+      if (!decode_mcu_fast(cinfo, MCU_data)) goto use_slow;
     }
     else {
+      use_slow:
       if (!decode_mcu_slow(cinfo, MCU_data)) return FALSE;
     }