Fix libjpeg_turbo svn r64 libjpeg6b compat issue
Make the fast path Huffman decoder fallback to the slow decoding path if
the Huffman decoding bit sentinel > 16, this to match libjpeg6b decoding
by reproducing the exact behavior of jpeg_huff_decode().
When this sentinel check is missing (see bug), libjpeg_turbo can produce
two (or more) different decoded images for the same input data depending
on how transport systems (eg., networks) packetize the data for delivery
to end-systems, web browsers for example.
Note: libjpeg6b produces the same decoded image, irrespective of how the
input data is placed in network packets. This fix makes libjpeg_turbo do
the same for compat with libjpeg6b.
TBR=darin@chromium.org
BUG=chromium:398235
Review URL: https://codereview.appspot.com/229430043
git-svn-id: http://src.chromium.org/svn/trunk/deps/third_party/libjpeg_turbo@295003 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
diff --git a/jdhuff.c b/jdhuff.c
index 6662107..5d023ae 100644
--- a/jdhuff.c
+++ b/jdhuff.c
@@ -663,7 +663,7 @@
d_derived_tbl * actbl = entropy->ac_cur_tbls[blkn];
register int s, k, r, l;
- HUFF_DECODE_FAST(s, l, dctbl);
+ HUFF_DECODE_FAST(s, l, dctbl, slow_decode_mcu);
if (s) {
FILL_BIT_BUFFER_FAST
r = GET_BITS(s);
@@ -680,7 +680,7 @@
if (entropy->ac_needed[blkn]) {
for (k = 1; k < DCTSIZE2; k++) {
- HUFF_DECODE_FAST(s, l, actbl);
+ HUFF_DECODE_FAST(s, l, actbl, slow_decode_mcu);
r = s >> 4;
s &= 15;
@@ -699,7 +699,7 @@
} else {
for (k = 1; k < DCTSIZE2; k++) {
- HUFF_DECODE_FAST(s, l, actbl);
+ HUFF_DECODE_FAST(s, l, actbl, slow_decode_mcu);
r = s >> 4;
s &= 15;
@@ -716,6 +716,7 @@
}
if (cinfo->unread_marker != 0) {
+slow_decode_mcu:
cinfo->unread_marker = 0;
return FALSE;
}