#44866 [Opn->Bgs]: curl CURLOPT_INFILE leaks handle reference
| From: | iliaa@php.net | Date: | Mon, 05 May 2008 23:04:04 +0000 |
| Subject: | #44866 [Opn->Bgs]: curl CURLOPT_INFILE leaks handle reference | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-124737@lists.php.net to get a copy of this message | ||
ID: 44866
Updated by: iliaa@php.net
Reported By: david at acz dot org
-Status: Open
+Status: Bogus
Bug Type: cURL related
Operating System: SLES 10 x86_64
PHP Version: 5.2.5
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
The file will be closed at the end of the request.
Previous Comments:
------------------------------------------------------------------------
[2008-04-30 01:05:03] david at acz dot org
Description:
------------
File handles are normally closed automatically when the reference count
hits zero. For example, if you fopen() something in a function and only
assign it to a local variable, the file is closed when the function
returns.
CURLOPT_INFILE breaks this behavior. Presumably, the curl resource
destructor does not decrement the reference count for the file handle.
Reproduce code:
---------------
<?
$name = tempnam("/tmp", "phpbug");
$n = count(scandir("/proc/self/fd"));
test_simple($name);
var_dump(count(scandir("/proc/self/fd")) == $n);
test_curl($name, true);
var_dump(count(scandir("/proc/self/fd")) == $n);
test_curl($name, false);
var_dump(count(scandir("/proc/self/fd")) == $n);
function test_simple($name)
{
$fp = fopen($name, "r");
}
function test_curl($name, $close)
{
$fp = fopen($name, "r");
$c = curl_init();
curl_setopt($c, CURLOPT_PUT, true);
curl_setopt($c, CURLOPT_INFILE, $fp);
curl_setopt($c, CURLOPT_INFILESIZE, 0);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_exec($c);
curl_close($c);
if ($close)
fclose($fp);
}
?>
Expected result:
----------------
bool(true)
bool(true)
bool(true)
Actual result:
--------------
bool(true)
bool(true)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44866&edit=1