From 2234deeeed40a51bf9611bd93c8b5a2b9fc945b6 Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 8 Nov 2019 13:51:34 -0600 Subject: [PATCH] Fix MSan use-of-uninitialized-value error ... introduced by 42825b68d570fb07fe820ac62ad91017e61e9a25. In fact, fault-tolerant multi-scan block smoothing cannot currently be used with the arithmetic decoder, because that decoder doesn't have any way of distinguishing a normal end of scan from an unexpected end of scan. Thus, this commit also modifies the change log to reset the expectations regarding the scope of the fault-tolerant multi-scan block smoothing feature. If, at some point in the future, the arithmetic decoder can be modified to detect an unexpected end of scan, then one would need only set entropy->pub.insufficient_data = TRUE when the arithmetic decoder encounters an unexpected end of scan in order to make fault-tolerant block smoothing work properly with that decoder. --- ChangeLog.md | 20 ++++++++++---------- jdarith.c | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index fd5e93c2..3d9daae7 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -57,16 +57,16 @@ and AMD CPUs, as well as a measured average overall compression speedup of 0-23% on platforms that do not have a SIMD-accelerated Huffman encoding implementation. -7. The block smoothing algorithm that the libjpeg API library optionally -applies when decompressing multi-scan images is now more fault-tolerant. -Previously, if a particular scan was incomplete, then the smoothing parameters -for the incomplete scan would be applied to the entire output image, including -the parts of the image that were generated by the prior (complete) scan. -Visually, this had the effect of removing block smoothing from lower-frequency -scans if they were followed by an incomplete higher-frequency scan. -libjpeg-turbo now applies block smoothing parameters to each iMCU row based on -which scan generated the pixels in that row, rather than always using the block -smoothing parameters for the most recent scan. +7. When decompressing progressive Huffman-encoded JPEG images, the block +smoothing algorithm that the libjpeg API library optionally applies is now more +fault-tolerant. Previously, if a particular scan was incomplete, then the +smoothing parameters for the incomplete scan would be applied to the entire +output image, including the parts of the image that were generated by the prior +(complete) scan. Visually, this had the effect of removing block smoothing +from lower-frequency scans if they were followed by an incomplete +higher-frequency scan. libjpeg-turbo now applies block smoothing parameters to +each iMCU row based on which scan generated the pixels in that row, rather than +always using the block smoothing parameters for the most recent scan. 2.0.3 diff --git a/jdarith.c b/jdarith.c index 8868d221..6f95cbc4 100644 --- a/jdarith.c +++ b/jdarith.c @@ -731,6 +731,7 @@ bad: entropy->c = 0; entropy->a = 0; entropy->ct = -16; /* force reading 2 initial bytes to fill C */ + entropy->pub.insufficient_data = FALSE; /* Initialize restart counter */ entropy->restarts_to_go = cinfo->restart_interval;