From fe6a2ee5a170ddc7b2983e49fedd71cc93f52d06 Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 18 Mar 2011 05:49:26 +0000 Subject: [PATCH] Throw a warning if an unexpected marker is found in the middle of the JPEG data stream git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.0.x@524 632fc199-4ca6-4c93-a231-07263d6284db --- ChangeLog.txt | 4 ++++ jdhuff.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 9b1c317c..531c31aa 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -20,6 +20,10 @@ It also ensures that the library can avoid the performance pitfall created by [4] Fixed visual artifacts in grayscale JPEG compression caused by a typo in the RGB-to-chrominance lookup tables. +[5] Fixed the accelerated Huffman decoder so that it mimics the behavior of +the unaccelerated decoder and throws a warning if an unexpected marker is found +in the middle of the JPEG data stream. + 1.0.1 ===== diff --git a/jdhuff.c b/jdhuff.c index 0291bc97..1342f3e9 100644 --- a/jdhuff.c +++ b/jdhuff.c @@ -621,6 +621,7 @@ decode_mcu_slow (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) if (val0 == 0xFF) { \ buffer++; \ if (val1 != 0) { \ + cinfo->unread_marker = val1; \ buffer -= 2; \ get_buffer &= ~0xFF; \ } \ @@ -737,6 +738,11 @@ 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; + } + br_state.bytes_in_buffer -= (buffer - br_state.next_input_byte); br_state.next_input_byte = buffer; BITREAD_SAVE_STATE(cinfo,entropy->bitstate);