svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/curl/interface.c branches/PHP_5_3/ext/curl/tests/bug52827.phpt
trunk/ext/curl/interface.c trunk/ext/curl/tests/bug52827.phpt
| From: | Adam Harvey | Date: | Tue, 14 Sep 2010 10:58:59 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/curl/interface.c branches/PHP_5_3/ext/curl/tests/bug52827.phpt trunk/ext/curl/interface.c trunk/ext/curl/tests/bug52827.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-63483@lists.php.net to get a copy of this message | ||
aharvey Tue, 14 Sep 2010 10:58:59 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=303361
Log:
Fix bug #52827 (cURL leaks handle and causes assertion error (CURLOPT_STDERR)).
Patch by Gustavo.
Bug: http://bugs.php.net/52827 (Assigned) cURL leaks handle
and causes assertion error (CURLOPT_STDERR)
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/ext/curl/interface.c
A php/php-src/branches/PHP_5_3/ext/curl/tests/bug52827.phpt
U php/php-src/trunk/ext/curl/interface.c
A php/php-src/trunk/ext/curl/tests/bug52827.phpt
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2010-09-14 10:43:30 UTC (rev 303360)
+++ php/php-src/branches/PHP_5_3/NEWS 2010-09-14 10:58:59 UTC (rev 303361)
@@ -21,6 +21,8 @@
- Fixed possible crash in mssql_fetch_batch(). (Kalle)
- Fixed inconsistent backlog default value (-1) in FPM on many systems. (fat)
+- Fixed bug #52827 (cURL leaks handle and causes assertion error
+ (CURLOPT_STDERR)). (Gustavo)
- Fixed bug #52786 (PHP should reset section to [PHP] after ini sections).
(Fedora at famillecollet dot com)
- Fixed bug #52772 (var_dump() doesn't check for the existence of
Modified: php/php-src/branches/PHP_5_3/ext/curl/interface.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/curl/interface.c 2010-09-14 10:43:30 UTC (rev 303360)
+++ php/php-src/branches/PHP_5_3/ext/curl/interface.c 2010-09-14 10:58:59 UTC (rev 303361)
@@ -1816,7 +1816,6 @@
}
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;
Added: php/php-src/branches/PHP_5_3/ext/curl/tests/bug52827.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/curl/tests/bug52827.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/curl/tests/bug52827.phpt 2010-09-14 10:58:59 UTC (rev 303361)
@@ -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.
Modified: php/php-src/trunk/ext/curl/interface.c
===================================================================
--- php/php-src/trunk/ext/curl/interface.c 2010-09-14 10:43:30 UTC (rev 303360)
+++ php/php-src/trunk/ext/curl/interface.c 2010-09-14 10:58:59 UTC (rev 303361)
@@ -1826,7 +1826,6 @@
}
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;
Added: php/php-src/trunk/ext/curl/tests/bug52827.phpt
===================================================================
--- php/php-src/trunk/ext/curl/tests/bug52827.phpt (rev 0)
+++ php/php-src/trunk/ext/curl/tests/bug52827.phpt 2010-09-14 10:58:59 UTC (rev 303361)
@@ -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.