'incorrect checksum for freed object' libcurl using https on osx
===

i keep getting 'incorrect checksum for freed object' errors when i try to execute a curl command on a https url. This is only happening on my osx developer machine, when i execute the same code on a ubuntu server it doesn't happen. I also tried it on other osx setups and it's giving the same error on every machine.

I'm running Mac OSX 10.7.4 with php 5.4 installed via http://php-osx.liip.ch/

This is a part of the error i get in my console:

    Parent Process:  httpd [2228]

    PlugIn Path:       /usr/local/php5/lib/libcurl.4.dylib
    PlugIn Identifier: libcurl.4.dylib
    PlugIn Version:    7.0.0 (compatibility 7.0.0)

    Date/Time:       2012-07-31 09:30:50.602 +0200
    OS Version:      Mac OS X 10.7.4 (11E53)
    Report Version:  9

    Crashed Thread:  0  Dispatch queue: com.apple.main-thread

    Exception Type:  EXC_CRASH (SIGABRT)
    Exception Codes: 0x0000000000000000, 0x0000000000000000

    Application Specific Information:
    *** error for object 0x7fd15c8274f8: incorrect checksum for freed object - object was probably modified after being freed.

The code that causes this error is the following:

    function __doRequest($request, $location, $action, $version, $one_way = null)
    {
        stream_wrapper_unregister('https');
        stream_wrapper_unregister('http');
        stream_wrapper_register('https', '<namespace>\\streamWrapperHttpAuth');
        stream_wrapper_register('http', '<namespace>\\streamWrapperHttpAuth');

        $headers = array(
            'User-Agent: PHP-SOAP', 'Content-Type: text/xml;charset=UTF-8', 'SOAPAction: "' . $action . '"', 'Content-Length: ' . strlen($request), 'Expect: 100-continue', 'Connection: Keep-Alive'
        );

        $this->__last_request_headers = $headers;
        $ch                           = curl_init($location);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $request);

        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
        curl_setopt($ch, CURLOPT_FAILONERROR, FALSE);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);

        curl_setopt($ch, CURLOPT_USERPWD, $this->Username . ':' . $this->Password);
        curl_setopt($ch, CURLOPT_SSLVERSION, 3);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        //curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
        curl_setopt($ch, CURLOPT_CERTINFO, TRUE);

        $response = curl_exec($ch);

        if (($info = curl_getinfo($ch)) && $info['http_code'] == 200) {
            return $response;
        }
        else if ($info['http_code'] == 401) {
            throw new \Exception ('Access Denied', 401);
        }
        else if (curl_errno($ch) != 0) {
            throw new \Exception(curl_error($ch) . curl_errno($ch) . $location, curl_errno($ch));
        }
        else {
            //throw new \Exception($response, $info['http_code']);
            return $response;
        }

        stream_wrapper_restore('https');
        stream_wrapper_restore('http');
    }

The error is thrown on the following line: '$response = curl_exec($ch);', when the webservices where called over http in stead of https it worked.