@@ -1980,7 +1980,7 @@ PHP_FUNCTION(curl_copy_handle)
1980
1980
dupch -> to_free = ch -> to_free ;
1981
1981
1982
1982
/* Keep track of cloned copies to avoid invoking curl destructors for every clone */
1983
- ZVAL_COPY ( & dupch -> clone , & ch -> clone ) ;
1983
+ ch -> clone ++ ;
1984
1984
1985
1985
ZEND_REGISTER_RESOURCE (return_value , dupch , le_curl );
1986
1986
dupch -> res = Z_RES_P (return_value );
@@ -2583,8 +2583,10 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue TSRMLS_DC) /
2583
2583
return FAILURE ;
2584
2584
}
2585
2585
2586
- if (Z_REFCOUNTED ( ch -> clone ) && Z_REFCOUNT ( ch -> clone ) <= 1 ) {
2586
+ if (ch -> clone == 0 ) {
2587
2587
zend_llist_clean (& ch -> to_free -> post );
2588
+ } else {
2589
+ -- ch -> clone ;
2588
2590
}
2589
2591
zend_llist_add_element (& ch -> to_free -> post , & first );
2590
2592
error = curl_easy_setopt (ch -> cp , CURLOPT_HTTPPOST , first );
@@ -3167,14 +3169,14 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
3167
3169
curl_easy_cleanup (ch -> cp );
3168
3170
3169
3171
/* cURL destructors should be invoked only by last curl handle */
3170
- if (Z_ISUNDEF ( ch -> clone ) ) {
3172
+ if (ch -> clone == 0 ) {
3171
3173
zend_llist_clean (& ch -> to_free -> str );
3172
3174
zend_llist_clean (& ch -> to_free -> post );
3173
3175
zend_hash_destroy (ch -> to_free -> slist );
3174
3176
efree (ch -> to_free -> slist );
3175
3177
efree (ch -> to_free );
3176
3178
} else {
3177
- //??? Z_DELREF( ch->clone) ;
3179
+ -- ch -> clone ;
3178
3180
}
3179
3181
3180
3182
smart_str_free (& ch -> handlers -> write -> buf );
0 commit comments