|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54798 Segfault when CURLOPT_STDERR file pointer is closed before calling curl_exec
Submitted: 2011-05-17 16:25 UTC Modified: 2011-09-12 09:19 UTC
From: Assigned: bjori
Status: Closed Package: cURL related
PHP Version: trunk-SVN-2011-05-17 (SVN) OS: Ubuntu Linux 11.04 x86
Private report: No CVE-ID:
 [2011-05-17 16:25 UTC]
Related to

Curl crashes when CURLOPT_STDERR file pointer is closed before calling 
curl_exec(), i.e.

$fp = fopen(dirname(__FILE__) . '/bug48203.tmp', 'w');

$ch = curl_init();

curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, $fp);
curl_setopt($ch, CURLOPT_URL, getenv("PHP_CURL_HTTP_REMOTE_SERVER"));

fclose($fp); // <-- premature close of $fp caused a crash!

curl_exec($ch); // segfault

Error is reproduced on latest svn php5.3, php5.4 and trunk
Fix is also attached here.

Test script:
Full test script is available here:

Expected result:
No segfault, see test script

Actual result:


fix-bug54798 (last revision 2011-05-17 14:26 UTC) by confik at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-06-12 02:14 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: iliaa
 [2011-09-08 12:33 UTC]
-Assigned To: iliaa +Assigned To: bjori
 [2011-09-08 14:37 UTC]
Automatic comment from SVN on behalf of bjori
Log: Fixed bug#54798	Segfault when CURLOPT_STDERR file pointer is closed before calling curl_exec
 [2011-09-08 14:37 UTC]
-Status: Assigned +Status: Closed
 [2011-09-08 14:37 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

 [2011-09-09 11:36 UTC]
-Status: Closed +Status: Assigned
 [2011-09-09 11:36 UTC]
The fix was wrong, reopening bug, see discussion over here: and here
 [2011-09-12 09:19 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Tue Oct 13 08:01:52 2015 UTC