From 7a35bcac1a89f44f47c8a8c4a08a98ac165a2a4b Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Sat, 4 Apr 2015 08:45:34 -0500 Subject: [PATCH] [libpng17] Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler (Bug report by Viktor Szaka'ts). --- ANNOUNCE | 10 +++++++--- CHANGES | 8 ++++++-- png.c | 6 +++--- pngmem.c | 3 +++ pngpread.c | 2 -- pngrutil.c | 3 ++- pngset.c | 4 +++- pngtrans.c | 2 +- 8 files changed, 25 insertions(+), 13 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index af80daf11..c3451fd90 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.7.0beta59 - March 31, 2015 +Libpng 1.7.0beta59 - April 4, 2015 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. @@ -779,7 +779,7 @@ Version 1.7.0beta58 [March 25, 2015] condition on RELEASE (or not) builds and tidy up the #ifdef handling of functions. -Version 1.7.0beta59 [March 31, 2015] +Version 1.7.0beta59 [April 4, 2015] Transformed rewrite: changed row_info, added checks. This introduces an internal struct (png_transform_control) to replace row_info and uses that to implement affirms correctly. The change also adds checks on @@ -789,7 +789,11 @@ Version 1.7.0beta59 [March 31, 2015] review of previous checks, removal of some where SAFE. pngvalid: add testing of tRNS for better code coverage pngvalid: correct rgb-to-gray error calculations. Code coverage is still incomplete: see /*UNTESTED*/ - in pngrtran.c + in pngrtran.c. This fixes some arithmetic errors that caused some tests + to fail on some 32-bit platforms (Bug reports by Peter Breitenlohner [i686] + and Petr Gajdos [i586]). + Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler + (Bug report by Viktor Szaka'ts). Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index 7532a8bb7..3efa3c646 100644 --- a/CHANGES +++ b/CHANGES @@ -5069,7 +5069,7 @@ Version 1.7.0beta58 [March 25, 2015] condition on RELEASE (or not) builds and tidy up the #ifdef handling of functions. -Version 1.7.0beta59 [March 31, 2015] +Version 1.7.0beta59 [April 4, 2015] Transformed rewrite: changed row_info, added checks. This introduces an internal struct (png_transform_control) to replace row_info and uses that to implement affirms correctly. The change also adds checks on @@ -5079,7 +5079,11 @@ Version 1.7.0beta59 [March 31, 2015] review of previous checks, removal of some where SAFE. pngvalid: add testing of tRNS for better code coverage pngvalid: correct rgb-to-gray error calculations. Code coverage is still incomplete: see /*UNTESTED*/ - in pngrtran.c + in pngrtran.c. This fixes some arithmetic errors that caused some tests + to fail on some 32-bit platforms (Bug reports by Peter Breitenlohner [i686] + and Petr Gajdos [i586]). + Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler + (Bug report by Viktor Szaka'ts). Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/png.c b/png.c index d362853f0..1687439aa 100644 --- a/png.c +++ b/png.c @@ -689,13 +689,13 @@ png_get_copyright(png_const_structrp png_ptr) #else # ifdef __STDC__ return PNG_STRING_NEWLINE \ - "libpng version 1.7.0beta59 - March 31, 2015" PNG_STRING_NEWLINE \ + "libpng version 1.7.0beta59 - April 4, 2015" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ PNG_STRING_NEWLINE; # else - return "libpng version 1.7.0beta59 - March 31, 2015\ + return "libpng version 1.7.0beta59 - April 4, 2015\ Copyright (c) 1998-2015 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; @@ -2180,7 +2180,7 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, /* Length *and* intent must match */ if (length == png_sRGB_checks[i].length && - intent == png_sRGB_checks[i].intent) + intent == (png_uint_32) png_sRGB_checks[i].intent) { /* Now calculate the adler32 if not done already. */ if (adler == 0) diff --git a/pngmem.c b/pngmem.c index d6f529674..493c4252c 100644 --- a/pngmem.c +++ b/pngmem.c @@ -78,6 +78,9 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size), PNG_UNUSED(png_ptr) #endif + /* Some compilers complain that this is always true. However, it + * can be false when integer overflow happens. + */ if (size > 0 && size <= PNG_SIZE_MAX # ifdef PNG_MAX_MALLOC_64K && size <= 65536U diff --git a/pngpread.c b/pngpread.c index 547b19d9e..f62da1d6f 100644 --- a/pngpread.c +++ b/pngpread.c @@ -584,13 +584,11 @@ png_push_save_buffer(png_structrp png_ptr) if (png_ptr->save_buffer == NULL) { png_free(png_ptr, old_buffer); - old_buffer = NULL; png_error(png_ptr, "Insufficient memory for save_buffer"); } memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); png_free(png_ptr, old_buffer); - old_buffer = NULL; png_ptr->save_buffer_max = new_max; } if (png_ptr->current_buffer_size) diff --git a/pngrutil.c b/pngrutil.c index 0bc5ea838..49132f002 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -1803,7 +1803,8 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) return; } - if (length > png_ptr->num_palette || length > PNG_MAX_PALETTE_LENGTH || + if (length > png_ptr->num_palette || + length > (unsigned int) PNG_MAX_PALETTE_LENGTH || length == 0) { png_crc_finish(png_ptr, length); diff --git a/pngset.c b/pngset.c index bfa9def0d..23ee20829 100644 --- a/pngset.c +++ b/pngset.c @@ -677,7 +677,6 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, if (new_iccp_profile == NULL) { png_free(png_ptr, new_iccp_name); - new_iccp_name = NULL; png_benign_error(png_ptr, "Insufficient memory to process iCCP profile"); @@ -1562,6 +1561,9 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size) } #ifndef __COVERITY__ + /* Some compilers complain that this is always false. However, it + * can be true when integer overflow happens. + */ if (size > ZLIB_IO_MAX) { png_warning(png_ptr, diff --git a/pngtrans.c b/pngtrans.c index 5997bef8d..414a66dfd 100644 --- a/pngtrans.c +++ b/pngtrans.c @@ -683,7 +683,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, */ for (; rp > png_ptr->row_buf; rp--) { - if (*rp >> padding != 0) + if ((*rp >> padding) != 0) png_ptr->num_palette_max = 1; padding = 0; }