|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-06-24 14:21 UTC] felix-php at 7val dot com
[2009-06-26 23:19 UTC] jani@php.net
[2009-06-29 12:43 UTC] felix-php at 7val dot com
[2009-09-10 08:02 UTC] sjoerd@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 17:00:02 2025 UTC |
Description: ------------ When passing an open, writable file handle to Curl as the CURLOPT_FILE option, the refcount to that file handle is increased without being decreased when calling curl_close. Thus the file handle has to be closed TWICE to actually being flushed and closed. In the reproduce code the file handle is still a valid resource after the first call to fclose(). The bug is reproducable in PHP 5.2.10. In 5.2.9 the code works as expected. In 5.2.10 in ext/curl/interface.c:1440 the call zend_list_addref(Z_LVAL_PP(zvalue)); was added. Maybe the problem origins here, if there is no corresponding delref in curl_close()? Reproduce code: --------------- $fh = fopen('curl.out', 'w'); $c = curl_init('http://example.com'); curl_setopt($c, CURLOPT_FILE, $fh); curl_exec($c); fclose($fh); echo "content 1: ". file_get_contents('curl.out') ."\n"; if (is_resource($fh)) { echo "file still open -> wrong\n"; } else { echo "file closed -> correct\n"; exit; } fclose($fh); if (is_resource($fh)) { echo "file open 2\n"; } curl_close($c); echo "content 2: ". file_get_contents('curl.out') ."\n"; Expected result: ---------------- content 1: <HTML> <HEAD> <TITLE>Example Web Page</TITLE> </HEAD> [..] file closed -> correct Actual result: -------------- content 1: file still open -> wrong content 2: <HTML> <HEAD> <TITLE>Example Web Page</TITLE> </HEAD> [..]