pierrick                                 Mon, 21 Nov 2011 02:44:28 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=319594

Log:
Fix memory leak

Changed paths:
    U   php/php-src/branches/PHP_5_4/ext/curl/interface.c
    U   php/php-src/trunk/ext/curl/interface.c

Modified: php/php-src/branches/PHP_5_4/ext/curl/interface.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/curl/interface.c   2011-11-21 02:29:24 UTC 
(rev 319593)
+++ php/php-src/branches/PHP_5_4/ext/curl/interface.c   2011-11-21 02:44:28 UTC 
(rev 319594)
@@ -2035,6 +2035,7 @@
                                        char *string_key = NULL;
                                        uint  string_key_len;
                                        ulong num_key;
+                                       int numeric_key;

                                        SEPARATE_ZVAL(current);
                                        convert_to_string_ex(current);
@@ -2045,6 +2046,9 @@
                                        if(!string_key) {
                                                spprintf(&string_key, 0, "%ld", 
num_key);
                                                string_key_len = 
strlen(string_key)+1;
+                                               numeric_key = 1;
+                                       } else {
+                                               numeric_key = 0;
                                        }

                                        postval = Z_STRVAL_PP(current);
@@ -2088,6 +2092,10 @@
                                                                                
         CURLFORM_CONTENTSLENGTH, (long)Z_STRLEN_PP(current),
                                                                                
         CURLFORM_END);
                                        }
+
+                                       if (numeric_key) {
+                                               efree(string_key);
+                                       }
                                }

                                SAVE_CURL_ERROR(ch, error);

Modified: php/php-src/trunk/ext/curl/interface.c
===================================================================
--- php/php-src/trunk/ext/curl/interface.c      2011-11-21 02:29:24 UTC (rev 
319593)
+++ php/php-src/trunk/ext/curl/interface.c      2011-11-21 02:44:28 UTC (rev 
319594)
@@ -2035,6 +2035,7 @@
                                        char  *string_key = NULL;
                                        uint   string_key_len;
                                        ulong  num_key;
+                                       int    numeric_key;

                                        SEPARATE_ZVAL(current);
                                        convert_to_string_ex(current);
@@ -2045,6 +2046,9 @@
                                        if(!string_key) {
                                                spprintf(&string_key, 0, "%ld", 
num_key);
                                                string_key_len = 
strlen(string_key)+1;
+                                               numeric_key = 1;
+                                       } else {
+                                               numeric_key = 0;
                                        }

                                        postval = Z_STRVAL_PP(current);
@@ -2088,6 +2092,10 @@
                                                                                
         CURLFORM_CONTENTSLENGTH, (long)Z_STRLEN_PP(current),
                                                                                
         CURLFORM_END);
                                        }
+
+                                       if (numeric_key) {
+                                               efree(string_key);
+                                       }
                                }

                                SAVE_CURL_ERROR(ch, error);

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

Reply via email to