ID:               36813
 Updated by:       [EMAIL PROTECTED]
 Reported By:      olaf at 7val dot com
-Status:           Open
+Status:           Closed
 Bug Type:         cURL related
 Operating System: Linux
 PHP Version:      5.1.2
 New Comment:

Works fine -> closed.


Previous Comments:
------------------------------------------------------------------------

[2006-03-21 17:19:43] olaf at 7val dot com

Accidentally changed Summary, reverted it

------------------------------------------------------------------------

[2006-03-21 17:17:19] olaf at 7val dot com

CVS sanpshot works fine for me

------------------------------------------------------------------------

[2006-03-21 15:38:46] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip

Appears to work fine in latest CVS.

------------------------------------------------------------------------

[2006-03-21 14:10:37] olaf at 7val dot com

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


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=36813&edit=1

Reply via email to