aboutsummaryrefslogtreecommitdiff
path: root/perl/Curl_easy/easy.xs
diff options
context:
space:
mode:
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;
}
}