[libpng16] Quieted Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c,

pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt
would only work with iTXt chunks with length 255 or less.

Fixed cexcept.h in which GCC 5 reported that one of the auto
variables in the Try macro needs to be volatile to prevent value
being lost over the setjmp, and fixed g++ build breaks (John Bowler).
This commit is contained in:
Glenn Randers-Pehrson
2015-06-03 22:52:33 -05:00
parent a671f8baea
commit 77476d3c37
7 changed files with 28 additions and 21 deletions

14
png.c
View File

@@ -689,13 +689,13 @@ png_get_copyright(png_const_structrp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
"libpng version 1.7.0beta63 - June 1, 2015" PNG_STRING_NEWLINE \
"libpng version 1.7.0beta63 - June 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.0beta63 - June 1, 2015\
return "libpng version 1.7.0beta63 - June 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.";
@@ -2747,7 +2747,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
if (fp >= DBL_MIN && fp <= DBL_MAX)
{
int exp_b10; /* A base 10 exponent */
int exp_b10; /* A base 10 exponent */
double base; /* 10^exp_b10 */
/* First extract a base 10 exponent of the number,
@@ -2795,7 +2795,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
*/
{
int czero, clead, cdigits;
unsigned int czero, clead, cdigits;
char exponent[10];
/* Allow up to two leading zeros - this will not lengthen
@@ -2825,7 +2825,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
* of the loop don't break the number into parts so
* that the final digit is rounded.
*/
if (cdigits+czero-clead+1 < (int)precision)
if (cdigits+czero+1 < precision+clead)
fp = modf(fp, &d);
else
@@ -2931,7 +2931,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
*ascii++ = png_check_char(png_ptr, 48 + (int)d), ++cdigits;
}
}
while (cdigits+czero-clead < (int)precision && fp > DBL_MIN);
while (cdigits+czero < precision+clead && fp > DBL_MIN);
/* The total output count (max) is now 4+precision */
@@ -2999,7 +2999,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
/* Need another size check here for the exponent digits, so
* this need not be considered above.
*/
if ((int)size > cdigits)
if (size > cdigits)
{
while (cdigits > 0) *ascii++ = exponent[--cdigits];