From: glennrp Date: Thu, 25 Mar 2010 01:53:17 +0000 (+0000) Subject: Updated setjmp/longjmp/jmpbuf usage in png.c to work with libpng-1.5.0 X-Git-Tag: 7.0.1-0~9742 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5d750a4a8ed1a941c41de5e404f9699ae9eb4162;p=imagemagick Updated setjmp/longjmp/jmpbuf usage in png.c to work with libpng-1.5.0 --- diff --git a/ChangeLog b/ChangeLog index 17ea49fb0..6ced81a92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2010-03-24 6.6.0-9 Glenn Randers-Pehrson * coders/png.c: Eliminated support of libpng versions older than 1.0.12. * Relocated the new, misplaced png_get_rowbytes() call. + * Updated setjmp/longjmp/jmpbuf usage to work with libpng-1.5. 2010-03-21 6.6.0-9 Cristy * Windows does not support complex.h (reference diff --git a/coders/png.c b/coders/png.c index e5a025b61..66415ff4f 100644 --- a/coders/png.c +++ b/coders/png.c @@ -83,7 +83,7 @@ /* Suppress libpng pedantic warnings that were added in * libpng-1.2.41 and libpng-1.4.0. If you are working on - * migration to libpng-2.0, remove these defines and then + * migration to libpng-1.5, remove these defines and then * fix any code that generates warnings. */ /* #define PNG_DEPRECATED Use of this function is deprecated */ @@ -1435,7 +1435,11 @@ static void PNGErrorHandler(png_struct *ping,png_const_charp message) " libpng-%s error: %s", PNG_LIBPNG_VER_STRING,message); (void) ThrowMagickException(&image->exception,GetMagickModule(),CoderError, message,"`%s'",image->filename); +#if PNG_LIBPNG_VER < 10500 longjmp(ping->jmpbuf,1); +#else + png_longjmp(ping,1); +#endif } static void PNGWarningHandler(png_struct *ping,png_const_charp message) @@ -1788,7 +1792,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } png_pixels=(unsigned char *) NULL; - if (setjmp(ping->jmpbuf)) + if (setjmp(png_jmpbuf(ping))) { /* PNG image is corrupt. @@ -2331,7 +2335,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, /* Convert PNG pixels to pixel packets. */ - if (setjmp(ping->jmpbuf)) + if (setjmp(png_jmpbuf(ping))) { /* PNG image is corrupt. @@ -6434,7 +6438,7 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, png_set_write_fn(ping,image,png_put_data,png_flush_data); png_pixels=(unsigned char *) NULL; - if (setjmp(ping->jmpbuf)) + if (setjmp(png_jmpbuf(ping))) { /* PNG write failed. @@ -6885,8 +6889,7 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, if ((y == (long) image->rows) && (x == (long) image->columns)) { /* - No transparent pixels are present. Change 4 or 6 to 0 or 2, - and do not set the PNG_INFO_tRNS flag in ping_info->valid. + No transparent pixels are present. Change 4 or 6 to 0 or 2. */ image_matte=MagickFalse; ping_color_type&=0x03; @@ -7539,7 +7542,7 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, /* Initialize image scanlines. */ - if (setjmp(ping->jmpbuf)) + if (setjmp(png_jmpbuf(ping))) { /* PNG write failed.