From: Takeshi Abe Date: Wed, 1 Apr 2009 16:06:56 +0000 (+0000) Subject: MFH: X-Git-Tag: php-5.3.0RC2~235 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=335ba19297e6cef54883ad62ce46f95cc0f03356;p=php MFH: replaced static gdPngJmpbufStruct, which is afraid of being shared with several threads, by a couple of auto variables. --- diff --git a/ext/gd/libgd/gd_png.c b/ext/gd/libgd/gd_png.c index 6b9c81ec99..da5a32f682 100644 --- a/ext/gd/libgd/gd_png.c +++ b/ext/gd/libgd/gd_png.c @@ -41,14 +41,12 @@ const char * gdPngGetVersionString() return PNG_LIBPNG_VER_STRING; } -#ifndef PNG_SETJMP_NOT_SUPPORTED +#ifdef PNG_SETJMP_SUPPORTED typedef struct _jmpbuf_wrapper { jmp_buf jmpbuf; } jmpbuf_wrapper; -static jmpbuf_wrapper gdPngJmpbufStruct; - static void gdPngErrorHandler (png_structp png_ptr, png_const_charp msg) { jmpbuf_wrapper *jmpbuf_ptr; @@ -117,6 +115,9 @@ gdImagePtr gdImageCreateFromPngPtr (int size, void *data) gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile) { png_byte sig[8]; +#ifdef PNG_SETJMP_SUPPORTED + jmpbuf_wrapper jbw; +#endif png_structp png_ptr; png_infop info_ptr; png_uint_32 width, height, rowbytes, w, h; @@ -148,8 +149,8 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile) return NULL; } -#ifndef PNG_SETJMP_NOT_SUPPORTED - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, &gdPngJmpbufStruct, gdPngErrorHandler, NULL); +#ifdef PNG_SETJMP_SUPPORTED + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, &jbw, gdPngErrorHandler, NULL); #else png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); #endif @@ -174,8 +175,8 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile) /* setjmp() must be called in every non-callback function that calls a * PNG-reading libpng function */ -#ifndef PNG_SETJMP_NOT_SUPPORTED - if (setjmp(gdPngJmpbufStruct.jmpbuf)) { +#ifdef PNG_SETJMP_SUPPORTED + if (setjmp(jbw.jmpbuf)) { php_gd_error("gd-png error: setjmp returns error condition"); png_destroy_read_struct(&png_ptr, &info_ptr, NULL); @@ -198,8 +199,6 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile) if (im == NULL) { php_gd_error("gd-png error: cannot allocate gdImage struct"); png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - gdFree(image_data); - gdFree(row_pointers); return NULL; } @@ -213,8 +212,8 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile) /* setjmp() must be called in every non-callback function that calls a * PNG-reading libpng function */ -#ifndef PNG_SETJMP_NOT_SUPPORTED - if (setjmp(gdPngJmpbufStruct.jmpbuf)) { +#ifdef PNG_SETJMP_SUPPORTED + if (setjmp(jbw.jmpbuf)) { php_gd_error("gd-png error: setjmp returns error condition"); png_destroy_read_struct(&png_ptr, &info_ptr, NULL); gdFree(image_data); @@ -475,9 +474,10 @@ void gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level, int basefilte png_infop info_ptr; volatile int transparent = im->transparent; volatile int remap = FALSE; +#ifdef PNG_SETJMP_SUPPORTED + jmpbuf_wrapper jbw; -#ifndef PNG_SETJMP_NOT_SUPPORTED - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, &gdPngJmpbufStruct, gdPngErrorHandler, NULL); + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, &jbw, gdPngErrorHandler, NULL); #else png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); #endif @@ -494,8 +494,8 @@ void gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level, int basefilte return; } -#ifndef PNG_SETJMP_NOT_SUPPORTED - if (setjmp (gdPngJmpbufStruct.jmpbuf)) { +#ifdef PNG_SETJMP_SUPPORTED + if (setjmp(jbw.jmpbuf)) { php_gd_error("gd-png error: setjmp returns error condition"); png_destroy_write_struct (&png_ptr, &info_ptr);