pierrick                                 Sat, 03 Dec 2011 23:43:44 +0000

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

Log:
The progress handle don't need to be allocated unless
curl_setopt with CURLOPT_PROGRESSFUNCTION is called

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

Modified: php/php-src/trunk/ext/curl/interface.c
===================================================================
--- php/php-src/trunk/ext/curl/interface.c      2011-12-03 23:40:38 UTC (rev 
320331)
+++ php/php-src/trunk/ext/curl/interface.c      2011-12-03 23:43:44 UTC (rev 
320332)
@@ -1643,7 +1643,7 @@
        (*ch)->handlers->write        = ecalloc(1, sizeof(php_curl_write));
        (*ch)->handlers->write_header = ecalloc(1, sizeof(php_curl_write));
        (*ch)->handlers->read         = ecalloc(1, sizeof(php_curl_read));
-       (*ch)->handlers->progress     = ecalloc(1, sizeof(php_curl_progress));
+       (*ch)->handlers->progress     = NULL;

        (*ch)->in_callback = 0;
        (*ch)->header.str_len = 0;
@@ -2447,7 +2447,9 @@
                case CURLOPT_PROGRESSFUNCTION:
                        curl_easy_setopt(ch->cp, CURLOPT_PROGRESSFUNCTION,      
curl_progress);
                        curl_easy_setopt(ch->cp, CURLOPT_PROGRESSDATA, ch);
-                       if (ch->handlers->progress->func_name) {
+                       if (NULL == ch->handlers->progress) {
+                               ch->handlers->progress = ecalloc(1, 
sizeof(php_curl_progress));
+                       } else if (ch->handlers->progress->func_name) {
                                
zval_ptr_dtor(&ch->handlers->progress->func_name);
                                ch->handlers->progress->fci_cache = 
empty_fcall_info_cache;
                        }
@@ -3020,9 +3022,6 @@
        if (ch->handlers->write_header->func_name) {
                zval_ptr_dtor(&ch->handlers->write_header->func_name);
        }
-       if (ch->handlers->progress->func_name) {
-               zval_ptr_dtor(&ch->handlers->progress->func_name);
-       }
        if (ch->handlers->passwd) {
                zval_ptr_dtor(&ch->handlers->passwd);
        }
@@ -3046,7 +3045,14 @@
        efree(ch->handlers->write);
        efree(ch->handlers->write_header);
        efree(ch->handlers->read);
-       efree(ch->handlers->progress);
+
+       if (ch->handlers->progress) {
+               if (ch->handlers->progress->func_name) {
+                       zval_ptr_dtor(&ch->handlers->progress->func_name);
+               }
+               efree(ch->handlers->progress);
+       }
+
        efree(ch->handlers);
        efree(ch);
 }
@@ -3093,12 +3099,13 @@
                ch->handlers->std_err = NULL;
        }

-       if (ch->handlers->progress->func_name) {
-               zval_ptr_dtor(&ch->handlers->progress->func_name);
-               ch->handlers->progress->fci_cache = empty_fcall_info_cache;
-               ch->handlers->progress->func_name = NULL;
+       if (ch->handlers->progress) {
+               if (ch->handlers->progress->func_name) {
+                       zval_ptr_dtor(&ch->handlers->progress->func_name);
+               }
+               efree(ch->handlers->progress);
+               ch->handlers->progress = NULL;
        }
-       ch->handlers->progress->method = 0;
 }
 /* }}} */


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

Reply via email to