cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl Perl Interface

From: Cris Bailiff <c.bailiff_at_awayweb.com>
Date: Sat, 16 Feb 2002 16:12:21 +1100

Paul Harrington wrote:
>
> It looks like CURLOPT_ERRORBUFFER is also broke.
>
> > Thanks, Paul, I'll have a look - do you have a specific example thats not working
> > for you?
>
> Take a look at the attached example. Tested on 7.9.2 and 7.9.4 causes a seg
> fault.

It shouldn't cause a segfault, but I don't get anything in errbuf in the test
scripts.

The problem turns out to be a scoping issue. Because the name of the variable is
stored away by easy.xs, the scope when it is later used (to find/fill in the perl
variable from the curl error message) could be different. Fully specifying the
name of the variable (for example, explicitly as a global) can fix this:

E.g

Curl::easy::setopt($curl, CURLOPT_ERRORBUFFER, "::errbuf");
my $retcode=Curl::easy::perform($curl);
if ($retcode !=0) {
    print STDERR "$retcode / $::errbuf\n";
}

Using just 'errbuf' (especially with 'use strict' and 'my $errbuf') doesn't work
properly. I'll fix all the tests/examples to show this. A better solution would
be to take a 'ref' to the errbuf variable, and follow that to fill it in later,
so it doesn't matter what scope it is in - I'll add that to the 'futures' list.

This change in 1.20, RSN.

Cris

Received on 2002-02-16