@@ -1509,10 +1509,22 @@ PHP_FUNCTION(curl_copy_handle)
1509
1509
1510
1510
dupch -> cp = cp ;
1511
1511
dupch -> uses = 0 ;
1512
+ if (ch -> handlers -> write -> stream ) {
1513
+ Z_ADDREF_P (dupch -> handlers -> write -> stream );
1514
+ dupch -> handlers -> write -> stream = ch -> handlers -> write -> stream ;
1515
+ }
1512
1516
dupch -> handlers -> write -> method = ch -> handlers -> write -> method ;
1513
1517
dupch -> handlers -> write -> type = ch -> handlers -> write -> type ;
1518
+ if (ch -> handlers -> read -> stream ) {
1519
+ Z_ADDREF_P (ch -> handlers -> read -> stream );
1520
+ }
1521
+ dupch -> handlers -> read -> stream = ch -> handlers -> read -> stream ;
1514
1522
dupch -> handlers -> read -> method = ch -> handlers -> read -> method ;
1515
1523
dupch -> handlers -> write_header -> method = ch -> handlers -> write_header -> method ;
1524
+ if (ch -> handlers -> write_header -> stream ) {
1525
+ Z_ADDREF_P (ch -> handlers -> write_header -> stream );
1526
+ }
1527
+ dupch -> handlers -> write_header -> stream = ch -> handlers -> write_header -> stream ;
1516
1528
1517
1529
dupch -> handlers -> write -> fp = ch -> handlers -> write -> fp ;
1518
1530
dupch -> handlers -> write_header -> fp = ch -> handlers -> write_header -> fp ;
@@ -1767,9 +1779,10 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
1767
1779
switch (option ) {
1768
1780
case CURLOPT_FILE :
1769
1781
if (((php_stream * ) what )-> mode [0 ] != 'r' || ((php_stream * ) what )-> mode [1 ] == '+' ) {
1770
- zend_list_addref ( Z_LVAL_PP ( zvalue ) );
1782
+ Z_ADDREF_PP ( zvalue );
1771
1783
ch -> handlers -> write -> fp = fp ;
1772
1784
ch -> handlers -> write -> method = PHP_CURL_FILE ;
1785
+ ch -> handlers -> write -> stream = * zvalue ;
1773
1786
} else {
1774
1787
php_error_docref (NULL TSRMLS_CC , E_WARNING , "the provided file handle is not writable" );
1775
1788
RETVAL_FALSE ;
@@ -1778,19 +1791,21 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
1778
1791
break ;
1779
1792
case CURLOPT_WRITEHEADER :
1780
1793
if (((php_stream * ) what )-> mode [0 ] != 'r' || ((php_stream * ) what )-> mode [1 ] == '+' ) {
1781
- zend_list_addref ( Z_LVAL_PP ( zvalue ) );
1794
+ Z_ADDREF_PP ( zvalue );
1782
1795
ch -> handlers -> write_header -> fp = fp ;
1783
1796
ch -> handlers -> write_header -> method = PHP_CURL_FILE ;
1797
+ ch -> handlers -> write_header -> stream = * zvalue ;
1784
1798
} else {
1785
1799
php_error_docref (NULL TSRMLS_CC , E_WARNING , "the provided file handle is not writable" );
1786
1800
RETVAL_FALSE ;
1787
1801
return 1 ;
1788
1802
}
1789
1803
break ;
1790
1804
case CURLOPT_INFILE :
1791
- zend_list_addref ( Z_LVAL_PP ( zvalue ) );
1805
+ Z_ADDREF_PP ( zvalue );
1792
1806
ch -> handlers -> read -> fp = fp ;
1793
1807
ch -> handlers -> read -> fd = Z_LVAL_PP (zvalue );
1808
+ ch -> handlers -> read -> stream = * zvalue ;
1794
1809
break ;
1795
1810
case CURLOPT_STDERR :
1796
1811
if (((php_stream * ) what )-> mode [0 ] != 'r' || ((php_stream * ) what )-> mode [1 ] == '+' ) {
@@ -2477,6 +2492,16 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
2477
2492
efree (ch -> header .str );
2478
2493
}
2479
2494
2495
+ if (ch -> handlers -> write_header -> stream ) {
2496
+ zval_ptr_dtor (& ch -> handlers -> write_header -> stream );
2497
+ }
2498
+ if (ch -> handlers -> write -> stream ) {
2499
+ zval_ptr_dtor (& ch -> handlers -> write -> stream );
2500
+ }
2501
+ if (ch -> handlers -> read -> stream ) {
2502
+ zval_ptr_dtor (& ch -> handlers -> read -> stream );
2503
+ }
2504
+
2480
2505
efree (ch -> handlers -> write );
2481
2506
efree (ch -> handlers -> write_header );
2482
2507
efree (ch -> handlers -> read );
0 commit comments