aboutsummaryrefslogtreecommitdiff
path: root/perl/Curl_easy/easy.xs
diff options
context:
space:
mode:
authorCris Bailiff <c.bailiff@awayweb.com>2001-09-10 09:17:02 +0000
committerCris Bailiff <c.bailiff@awayweb.com>2001-09-10 09:17:02 +0000
commit96c7253cea75dda86cde6ef5d3d7269843318bbf (patch)
treea67e5098dc4b84d746640f213703d5d11d4961ce /perl/Curl_easy/easy.xs
parent3f5227dfc7389f008137a6f4703af8022ab862f3 (diff)
Fix perl segfault due to changes in header callback behaviour since curl-7.8.1-pre3
Diffstat (limited to 'perl/Curl_easy/easy.xs')
-rw-r--r--perl/Curl_easy/easy.xs15
1 files changed, 11 insertions, 4 deletions
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;
}
}