#46711 [Opn->Csd]: cUrl leaks memory
| From: | iliaa@php.net | Date: | Sun, 30 Nov 2008 17:36:16 +0000 |
| Subject: | #46711 [Opn->Csd]: cUrl leaks memory | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-131496@lists.php.net to get a copy of this message | ||
ID: 46711
Updated by: iliaa@php.net
Reported By: thomas at koch dot ro
-Status: Open
+Status: Closed
Bug Type: cURL related
Operating System: Debian Lenny
PHP Version: 5.3CVS-2008-11-28 (CVS)
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2008-11-29 06:26:36] magicaltux@php.net
For reference: a test file for this bug (which uses the fact that the
array becomes corrupted).
http://ookoo.org/svn/snip/bug46711.phpt
------------------------------------------------------------------------
[2008-11-28 17:23:32] magicaltux@php.net
Just for info, I believe there's a bug somewhere.
After the foreach() loop, $opt looks like this:
array(2) {
[58]=>
NULL
[19914]=>
bool(true)
}
Assigning $value by reference in the foreach makes the bug disappear.
I had a look at xml_parser_set_option() (similar function) and tried to
make curl_set_opt() use the same way to get args, it seems to have fixed
the problem (haven't played enough with ZE yet to know for sure if it's
the correct fix).
Patch:
http://ookoo.org/svn/snip/php-5.3.0alpha3_curl_mem_bug.patch
------------------------------------------------------------------------
[2008-11-28 16:03:14] thomas at koch dot ro
Description:
------------
Setting cURL options in a foreach leaks memory
Reproduce code:
---------------
$ch = curl_init();
$opt = array(
CURLOPT_AUTOREFERER => TRUE,
CURLOPT_BINARYTRANSFER => TRUE
);
// This works fine:
//curl_setopt( $ch, CURLOPT_AUTOREFERER , TRUE );
//curl_setopt( $ch, CURLOPT_BINARYTRANSFER , TRUE );
// setting the options in a foreach leads to memory leaks
foreach( $opt as $option => $value ) {
curl_setopt( $ch, $option, $value );
}
Expected result:
----------------
no output
Actual result:
--------------
[Fri Nov 28 17:01:18 2008] Script: '/home/ymc-toko/curl_bug.php'
/var/checkouts/php5_3/ext/curl/interface.c(1505) : Freeing 0x030C6BE8
(32 bytes), script=/home/ymc-toko/curl_bug.php
[Fri Nov 28 17:01:18 2008] Script: '/home/ymc-toko/curl_bug.php'
/var/checkouts/php5_3/ext/curl/interface.c(1397) : Freeing 0x030C6C68
(32 bytes), script=/home/ymc-toko/curl_bug.php
=== Total 2 memory leaks detected ===
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46711&edit=1