Revert "Revert "Fixed warning "(null)(): supplied resource is not a valid cURL handle resource in Unknown on line 0"""

This reverts commit e78dd7ade2.
This commit is contained in:
Xinchen Hui 2015-02-02 10:32:26 +08:00
parent bf55a4e223
commit c9e44dc2df
2 changed files with 29 additions and 3 deletions

View File

@ -105,6 +105,10 @@ void _php_curl_multi_cleanup_list(void *data) /* {{{ */
return;
}
if (Z_RES_P(z_ch)->ptr == NULL) {
return;
}
ch = zend_fetch_resource(z_ch, -1, le_curl_name, NULL, 1, le_curl);
if (!ch) {
return;
@ -341,9 +345,11 @@ void _php_curl_multi_close(zend_resource *rsrc) /* {{{ */
for (pz_ch = (zval *)zend_llist_get_first_ex(&mh->easyh, &pos); pz_ch;
pz_ch = (zval *)zend_llist_get_next_ex(&mh->easyh, &pos)) {
ch = (php_curl *) zend_fetch_resource(pz_ch, -1, le_curl_name, NULL, 1, le_curl);
_php_curl_verify_handlers(ch, 0);
/* ptr is NULL means it already be freed */
if (Z_RES_P(pz_ch)->ptr) {
ch = (php_curl *) zend_fetch_resource(pz_ch, -1, le_curl_name, NULL, 1, le_curl);
_php_curl_verify_handlers(ch, 0);
}
}
curl_multi_cleanup(mh->multi);

View File

@ -0,0 +1,20 @@
--TEST--
curl_multi_close closed by cleanup functions
--SKIPIF--
<?php
if (!extension_loaded('curl')) print 'skip';
?>
--FILE--
<?php
$mh = curl_multi_init();
$array = array($mh);
$array[] = &$array;
curl_multi_add_handle($mh, curl_init());
curl_multi_add_handle($mh, curl_init());
curl_multi_add_handle($mh, curl_init());
curl_multi_add_handle($mh, curl_init());
echo "okey";
?>
--EXPECT--
okey