From 43c07e1b48e1a83a388a3f5bb6cf1f1e3a2887aa Mon Sep 17 00:00:00 2001 From: John Bowler Date: Sun, 7 Apr 2013 21:33:30 -0500 Subject: [PATCH] [libpng16] Fixed incorrect warning of excess deflate data. End condition - the warning would be produced if the end of the deflate stream wasn't read in the last row. The warning is harmless. --- ANNOUNCE | 7 +++++-- CHANGES | 5 ++++- pngrutil.c | 15 +++++++++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 6c6a730cd..f0972f2c6 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.6.2beta01 - April 1, 2013 +Libpng 1.6.2beta01 - April 8, 2013 This is not intended to be a public release. It will be replaced within a few weeks by a public version or by another test version. @@ -25,8 +25,11 @@ Other information: Changes since the last public release (1.6.1): -Version 1.6.2beta01 [April 1, 2013] +Version 1.6.2beta01 [April 8, 2013] Updated documentation of 1.5.x to 1.6.x changes in iCCP chunk handling. + Fixed incorrect warning of excess deflate data. End condition - the + warning would be produced if the end of the deflate stream wasn't read + in the last row. The warning is harmless. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index b2bcf5fc6..0263e22b0 100644 --- a/CHANGES +++ b/CHANGES @@ -4473,8 +4473,11 @@ Version 1.6.1rc01 [March 21, 2013] Version 1.6.1 [March 28, 2013] No changes. -Version 1.6.2beta01 [April 1, 2013] +Version 1.6.2beta01 [April 8, 2013] Updated documentation of 1.5.x to 1.6.x changes in iCCP chunk handling. + Fixed incorrect warning of excess deflate data. End condition - the + warning would be produced if the end of the deflate stream wasn't read + in the last row. The warning is harmless. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/pngrutil.c b/pngrutil.c index 3f4474c9b..f8d2df820 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -3983,7 +3983,7 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output, png_ptr->zstream.avail_out = out; } - else /* check for end */ + else /* after last row, checking for end */ { png_ptr->zstream.next_out = tmpbuf; png_ptr->zstream.avail_out = (sizeof tmpbuf); @@ -3998,10 +3998,13 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output, */ ret = inflate(&png_ptr->zstream, Z_NO_FLUSH); - /* Take the unconsumed output back (so, in the 'check' case this just - * counts up). - */ - avail_out += png_ptr->zstream.avail_out; + /* Take the unconsumed output back. */ + if (output != NULL) + avail_out += png_ptr->zstream.avail_out; + + else /* avail_out counts the extra bytes */ + avail_out += (sizeof tmpbuf) - png_ptr->zstream.avail_out; + png_ptr->zstream.avail_out = 0; if (ret == Z_STREAM_END) @@ -4040,7 +4043,7 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output, if (output != NULL) png_error(png_ptr, "Not enough image data"); - else /* checking */ + else /* the deflate stream contained extra data */ png_chunk_benign_error(png_ptr, "Too much image data"); } }