|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-03-21 15:38 UTC] iliaa@php.net
[2006-03-21 17:17 UTC] olaf at 7val dot com
[2006-03-21 17:19 UTC] olaf at 7val dot com
[2006-03-21 17:47 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 13:00:02 2025 UTC |
Description: ------------ curl_close causes a segfault when accessing a member variable after the call (see code below) when CURLOPT_RETURNTRANSFER is true and CURLOPT_HEADERFUNCTION is set to a member function. Calling curl_setopt($this->curl, CURLOPT_HEADERFUNCTION,array(&$this, 'readHeader')); again in __destruct (before curl_close) makes the segfault go away. Adding the line: zval_copy_ctor(ch->handlers->write_header->func_name); in ext/curl/interface.c line 1152 seems to fix it, but I don't know if it produces a memory leak. Reproduce code: --------------- <?php class CurlTest { var $curl; var $url; function readHeader($ch, $data) { return strlen($data); } function __construct($url) { $this->curl = curl_init($url); curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array(&$this, 'readHeader')); curl_setopt($this->curl, CURLOPT_URL, $url); $this->url = $url; } function __destruct() { if (is_resource($this->curl)) { curl_close($this->curl); } $x = $this->url; } function exec() { curl_exec($this->curl); } } $t = new CurlTest('http://www.google.de'); $t->exec(); $t = null; ?> Expected result: ---------------- No segfault Actual result: -------------- Segfault