diff options
| author | Adam Harvey <aharvey@php.net> | 2010-09-14 10:58:59 +0000 |
|---|---|---|
| committer | Adam Harvey <aharvey@php.net> | 2010-09-14 10:58:59 +0000 |
| commit | 56ea98734c193381540edd93a52cb456fe59c054 (patch) | |
| tree | 9638641370903926474bd1bc0d894fc05bb12cff | |
| parent | b6d8462ab21c00abdf19ecfbb15ec1ef9036d209 (diff) | |
| download | php-git-56ea98734c193381540edd93a52cb456fe59c054.tar.gz | |
Fix bug #52827 (cURL leaks handle and causes assertion error (CURLOPT_STDERR)).
Patch by Gustavo.
| -rw-r--r-- | ext/curl/interface.c | 1 | ||||
| -rw-r--r-- | ext/curl/tests/bug52827.phpt | 32 |
2 files changed, 32 insertions, 1 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c index edb4a30c87..24ff940c73 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1826,7 +1826,6 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu } zval_add_ref(zvalue); ch->handlers->std_err = *zvalue; - zend_list_addref(Z_LVAL_PP(zvalue)); } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "the provided file handle is not writable"); RETVAL_FALSE; diff --git a/ext/curl/tests/bug52827.phpt b/ext/curl/tests/bug52827.phpt new file mode 100644 index 0000000000..85a73fa797 --- /dev/null +++ b/ext/curl/tests/bug52827.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #52827 (curl_setopt with CURLOPT_STDERR erroneously increments the resource refcount) +--SKIPIF-- +<?php + +if (!extension_loaded('curl')) { + exit("skip curl extension not loaded"); +} + +?> +--FILE-- +<?php +$s = fopen('php://temp/maxmemory=1024','wb+'); + +/* force conversion of inner stream to STDIO. + * This is not necessary in Windows because the + * cast to a FILE* handle in curl_setopt already + * forces the conversion in that platform. The + * reason for this conversion is that the memory + * stream has an ugly but working mechanism to + * prevent being double freed when it's encapsulated, + * while STDIO streams don't. */ +$i = 0; +while ($i++ < 5000) { +fwrite($s, str_repeat('a',1024)); +} +$handle=curl_init('http://www.example.com'); +curl_setopt($handle, CURLOPT_STDERR, $s); + +echo "Done."; +--EXPECTF-- +Done. |
