|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40831 cURL extension doesnt clear buffer for reused handle
Submitted: 2007-03-15 23:00 UTC Modified: 2007-03-15 23:19 UTC
From: eion at bigfoot dot com Assigned:
Status: Closed Package: cURL related
PHP Version: 4.4.6 OS: Gentoo Linux
Private report: No CVE-ID: None
 [2007-03-15 23:00 UTC] eion at bigfoot dot com
Reusing a cURL request while using CURLOPT_RETURNTRANSFER=true causes the result of the first curl_exec() to still be in the body of the second curl_exec().  Possibly, buffer isnt being cleared.

I cant explain it properly, but the example code below should be able to.

This only happens on 4.4.6, and not on 4.4.4

Workaround is to use ob_start(); curl_exec($ch); $data=ob_get_clean();

Reproduce code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_URL, '');
$data1 = curl_exec($ch);

curl_setopt($ch, CURLOPT_URL, '');
$data2 = curl_exec($ch);

if (strpos($data2, $data1)===0)
	echo 'cURL Buffer is NOT being cleared';
} else {
	echo 'Everything ok';

Expected result:
Everything ok

Actual result:
cURL Buffer is NOT being cleared


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-15 23:19 UTC]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 14 20:01:31 2024 UTC