From 96c7253cea75dda86cde6ef5d3d7269843318bbf Mon Sep 17 00:00:00 2001 From: Cris Bailiff Date: Mon, 10 Sep 2001 09:17:02 +0000 Subject: Fix perl segfault due to changes in header callback behaviour since curl-7.8.1-pre3 --- perl/Curl_easy/Changes | 4 ++++ perl/Curl_easy/easy.pm | 4 ++-- perl/Curl_easy/easy.xs | 15 +++++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'perl/Curl_easy') diff --git a/perl/Curl_easy/Changes b/perl/Curl_easy/Changes index 22c7c8e00..c20dd29e6 100644 --- a/perl/Curl_easy/Changes +++ b/perl/Curl_easy/Changes @@ -1,6 +1,10 @@ Revision history for Perl extension Curl::easy. Check out the file README for more info. +1.1.6 Mon Sep 10 2001: - Cris Bailiff + - Fix segfault due to changes in header callback behaviour + since curl-7.8.1-pre3 + 1.1.5 Fri Apr 20 2001: - Cris Bailiff - Add latest CURLOPT_ and CURLINFO_ constants to the constants list diff --git a/perl/Curl_easy/easy.pm b/perl/Curl_easy/easy.pm index 8eeb89e17..0733de0c7 100644 --- a/perl/Curl_easy/easy.pm +++ b/perl/Curl_easy/easy.pm @@ -110,7 +110,7 @@ CURLINFO_CONTENT_LENGTH_UPLOAD USE_INTERNAL_VARS ); -$VERSION = '1.1.5'; +$VERSION = '1.1.6'; $Curl::easy::headers = ""; $Curl::easy::content = ""; @@ -254,7 +254,7 @@ indicate an error. Georg Horn -Additional callback,pod and tes work by Cris Bailiff +Additional callback,pod and test work by Cris Bailiff and Forrest Cahoon =head1 SEE ALSO diff --git a/perl/Curl_easy/easy.xs b/perl/Curl_easy/easy.xs index 6583b5ec5..dfe27b477 100644 --- a/perl/Curl_easy/easy.xs +++ b/perl/Curl_easy/easy.xs @@ -101,12 +101,14 @@ fwrite_wrapper (const void *ptr, if (stream == stdout) { sv = newSViv(0); /* FIXME: should cast stdout to GLOB somehow? */ - } else { /* its already an SV */ + } else if (stream == NULL) { + sv = &PL_sv_undef; + } else { /* its already an SV */ sv = stream; } if (ptr != NULL) { - XPUSHs(sv_2mortal(newSVpvn(ptr, size * nmemb))); + XPUSHs(sv_2mortal(newSVpvn((char *)ptr, (STRLEN)(size * nmemb)))); } else { XPUSHs(sv_2mortal(newSVpv("", 0))); } @@ -130,15 +132,20 @@ fwrite_wrapper (const void *ptr, } else { /* default to a normal 'fwrite' */ /* stream could be a FILE * or an SV * */ + /* or NULL since libcurl-7.8.1pre3 */ FILE *f; - if (stream == stdout) { /* the only possible FILE ? Think so */ + if (stream == stdout || + stream == NULL) { /* the only possible FILE ? Think so */ f = stream; } else { /* its a GLOB */ f = IoIFP(sv_2io(stream)); /* may barf if not a GLOB */ } - return fwrite(ptr, size, nmemb, f); + if (f) + return fwrite(ptr, size, nmemb, f); + else + return (size_t) size*nmemb; } } -- cgit v1.2.3