[libpng16] Fixed png_save_int_32 when int is not 2's complement (John Bowler).

This commit is contained in:
John Bowler 2015-08-21 14:42:00 -05:00 committed by Glenn Randers-Pehrson
parent 39be3b81da
commit 33a97c5c8a
3 changed files with 24 additions and 19 deletions

View File

@ -1,4 +1,4 @@
Libpng 1.6.19beta03 - August 19, 2015 Libpng 1.6.19beta03 - August 21, 2015
This is not intended to be a public release. It will be replaced 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. within a few weeks by a public version or by another test version.
@ -64,7 +64,8 @@ Version 1.6.19beta02 [August 19, 2015]
in ANSI-C (unlike 0x80000000 in the signed case) the checking that in ANSI-C (unlike 0x80000000 in the signed case) the checking that
occurs later can catch them (John Bowler). occurs later can catch them (John Bowler).
Version 1.6.19beta03 [August 19, 2015] Version 1.6.19beta03 [August 21, 2015]
Fixed png_save_int_32 when int is not 2's complement (John Bowler).
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

15
CHANGES
View File

@ -4421,7 +4421,7 @@ Version 1.6.1beta02 [February 19, 2013]
Version 1.6.1beta03 [February 22, 2013] Version 1.6.1beta03 [February 22, 2013]
Fixed ALIGNED_MEMORY support. Fixed ALIGNED_MEMORY support.
Allow run-time ARM NEON checking to be disabled. A new configure option: Added a new configure option:
--enable-arm-neon=always will stop the run-time checks. New checks --enable-arm-neon=always will stop the run-time checks. New checks
within arm/arm_init.c will cause the code not to be compiled unless within arm/arm_init.c will cause the code not to be compiled unless
__ARM_NEON__ is set. This should make it fail safe (if someone asks __ARM_NEON__ is set. This should make it fail safe (if someone asks
@ -4440,10 +4440,11 @@ Version 1.6.1beta05 [March 1, 2013]
Version 1.6.1beta06 [March 4, 2013] Version 1.6.1beta06 [March 4, 2013]
Better documentation of unknown handling API interactions. Better documentation of unknown handling API interactions.
Corrected Android builds and corrected libpng.vers with symbol Corrected Android builds and corrected libpng.vers with symbol
prefixing. This adds an API to set optimization options externally, prefixing. It also makes those tests
providing an alternative and general solution for the non-portable
run-time tests used by the ARM Neon code. It also makes those tests
compile and link on Android. compile and link on Android.
Added an API png_set_option() to set optimization options externally,
providing an alternative and general solution for the non-portable
run-time tests used by the ARM Neon code, using the PNG_ARM_NEON option.
The order of settings vs options in pnglibconf.h is reversed to allow The order of settings vs options in pnglibconf.h is reversed to allow
settings to depend on options and options can now set (or override) the settings to depend on options and options can now set (or override) the
defaults for settings. defaults for settings.
@ -4541,7 +4542,8 @@ Version 1.6.3beta05 [May 9, 2013]
Calculate our own zlib windowBits when decoding rather than trusting the Calculate our own zlib windowBits when decoding rather than trusting the
CMF bytes in the PNG datastream. CMF bytes in the PNG datastream.
Added an option to force maximum window size for inflating, which was Added an option to force maximum window size for inflating, which was
the behavior of libpng15 and earlier. the behavior of libpng15 and earlier, via a new PNG_MAXIMUM_INFLATE_WINDOW
option for png_set_options().
Added png-fix-itxt and png-fix-too-far-back to the built programs and Added png-fix-itxt and png-fix-too-far-back to the built programs and
removed warnings from the source code and timepng that are revealed as removed warnings from the source code and timepng that are revealed as
a result. a result.
@ -5344,7 +5346,8 @@ Version 1.6.19beta02 [August 19, 2015]
in ANSI-C (unlike 0x80000000 in the signed case) the checking that in ANSI-C (unlike 0x80000000 in the signed case) the checking that
occurs later can catch them (John Bowler). occurs later can catch them (John Bowler).
Version 1.6.19beta03 [August 19, 2015] Version 1.6.19beta03 [August 21, 2015]
Fixed png_save_int_32 when int is not 2's complement (John Bowler).
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

23
png.c
View File

@ -671,19 +671,20 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp)
# endif # endif
# ifdef PNG_SAVE_INT_32_SUPPORTED # ifdef PNG_SAVE_INT_32_SUPPORTED
/* The png_save_int_32 function assumes integers are stored in two's /* PNG signed integers are saved in 32-bit 2's complement format. ANSI C-90
* complement format. If this isn't the case, then this routine needs to * defines a cast of a signed integer to an unsigned integer either to preserve
* be modified to write data in two's complement format. Note that, * the value, if it is positive, or to calculate:
* the following works correctly even if png_int_32 has more than 32 bits *
* (compare the more complex code required on read for sign extension.) * (UNSIGNED_MAX+1) + integer
*
* Where UNSIGNED_MAX is the appropriate maximum unsigned value, so when the
* negative integral value is added the result will be an unsigned value
* correspnding to the 2's complement representation.
*/ */
void PNGAPI void PNGAPI
png_save_int_32(png_bytep buf, png_int_32 i) png_save_int_32(png_bytep buf, png_int_32 i)
{ {
buf[0] = (png_byte)((i >> 24) & 0xff); png_save_uint_32(buf, i);
buf[1] = (png_byte)((i >> 16) & 0xff);
buf[2] = (png_byte)((i >> 8) & 0xff);
buf[3] = (png_byte)(i & 0xff);
} }
# endif # endif
@ -774,13 +775,13 @@ png_get_copyright(png_const_structrp png_ptr)
#else #else
# ifdef __STDC__ # ifdef __STDC__
return PNG_STRING_NEWLINE \ return PNG_STRING_NEWLINE \
"libpng version 1.6.19beta03 - August 19, 2015" PNG_STRING_NEWLINE \ "libpng version 1.6.19beta03 - August 21, 2015" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE; PNG_STRING_NEWLINE;
# else # else
return "libpng version 1.6.19beta03 - August 19, 2015\ return "libpng version 1.6.19beta03 - August 21, 2015\
Copyright (c) 1998-2015 Glenn Randers-Pehrson\ Copyright (c) 1998-2015 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";