From: DRC Date: Sat, 16 Apr 2011 17:39:58 +0000 (+0000) Subject: The previous attempt to handle unexpected markers in the data stream caused breakage... X-Git-Tag: 1.1.1~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c36465fd581a84f3e1980515964e5d33ab62787;p=libjpeg-turbo The previous attempt to handle unexpected markers in the data stream caused breakage in applications that attempted to set bytes_in_buffer to a larger value than the actual size of the JPEG image. The latter behavior was causing the fast decoder to be used for the last MCU in the image under certain circumstances, and this sometimes caused the EOI marker to be encountered by the fast decoder, which was treating it as an "unexpected" marker and throwing an error. Now, the fast decoder simply hands off the decoding of the block to the slow decoder if any marker is encountered. git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@582 632fc199-4ca6-4c93-a231-07263d6284db --- diff --git a/jdhuff.c b/jdhuff.c index f6b6e00..ad1112e 100644 --- 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); @@ -793,9 +793,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; }