tabe            Wed Apr  1 16:06:56 2009 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/gd/libgd       gd_png.c 
  Log:
  MFH:
  replaced static gdPngJmpbufStruct, which is afraid of being shared with
  several threads, by a couple of auto variables.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd_png.c?r1=1.17.4.2.2.5.2.4&r2=1.17.4.2.2.5.2.5&diff_format=u
Index: php-src/ext/gd/libgd/gd_png.c
diff -u php-src/ext/gd/libgd/gd_png.c:1.17.4.2.2.5.2.4 
php-src/ext/gd/libgd/gd_png.c:1.17.4.2.2.5.2.5
--- php-src/ext/gd/libgd/gd_png.c:1.17.4.2.2.5.2.4      Sat Mar 14 16:08:00 2009
+++ php-src/ext/gd/libgd/gd_png.c       Wed Apr  1 16:06:56 2009
@@ -41,14 +41,12 @@
        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 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 @@
                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 @@
        /* 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 @@
        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 @@
        /* 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 @@
        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 @@
                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);
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to