From 53c750266395ca7a0017446dfb5167e470a19e75 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Fri, 30 Jul 2010 09:58:34 -0500 Subject: [PATCH] [devel] Added a typecast in png_get_int_32() to avoid compiler warning. --- ANNOUNCE | 3 +++ CHANGES | 3 +++ pngrutil.c | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 8ab9a21e0..93a346d8d 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -307,8 +307,11 @@ version 1.5.0beta36 [July 29, 2010] converting the values to the fixed point form used in the PNG file. The standard headers no longer include zlib.h, which is currently only required for pngstruct.h and can therefore be internal. + Revised png_get_int_32 to undo the PNG two's complement representation of + negative numbers. version 1.5.0beta37 [July 30, 2010] + Added a typecast in png_get_int_32() to avoid compiler warning. Send comments/corrections/commendations to png-mng-implement at lists.sf.net: (subscription required; visit diff --git a/CHANGES b/CHANGES index 852d036d9..6205db52b 100644 --- a/CHANGES +++ b/CHANGES @@ -2789,8 +2789,11 @@ version 1.5.0beta36 [July 29, 2010] converting the values to the fixed point form used in the PNG file. The standard headers no longer include zlib.h, which is currently only required for pngstruct.h and can therefore be internal. + Revised png_get_int_32 to undo the PNG two's complement representation of + negative numbers. version 1.5.0beta37 [July 30, 2010] + Added a typecast in png_get_int_32() to avoid compiler warning. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/pngrutil.c b/pngrutil.c index c25813f60..e801ecf78 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -77,11 +77,11 @@ png_int_32 (PNGAPI png_get_int_32)(png_bytep buf) { png_uint_32 u = png_get_uint_32(buf); - if ((u & 0x80000000) == 0) /* negative */ + if ((u & 0x80000000) == 0) /* non-negative */ return u; u = (u ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */ - return -u; + return -(png_int_32)u; } /* Grab an unsigned 16-bit integer from a buffer in big-endian format. */