diff options
Diffstat (limited to 'lib/base64.c')
-rw-r--r-- | lib/base64.c | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/lib/base64.c b/lib/base64.c index 66ddb329c..0c492dc45 100644 --- a/lib/base64.c +++ b/lib/base64.c @@ -31,10 +31,10 @@ #include <curl/mprintf.h> #include "urldata.h" /* for the SessionHandle definition */ -#include "easyif.h" /* for Curl_convert_... prototypes */ #include "warnless.h" #include "curl_base64.h" #include "curl_memory.h" +#include "non-ascii.h" /* include memdebug.h last */ #include "memdebug.h" @@ -146,9 +146,7 @@ size_t Curl_base64_encode(struct SessionHandle *data, int inputparts; char *output; char *base64data; -#ifdef CURL_DOES_CONVERSIONS char *convbuf = NULL; -#endif const char *indata = inputbuff; @@ -161,29 +159,16 @@ size_t Curl_base64_encode(struct SessionHandle *data, if(NULL == output) return 0; -#ifdef CURL_DOES_CONVERSIONS /* * The base64 data needs to be created using the network encoding * not the host encoding. And we can't change the actual input * so we copy it to a buffer, translate it, and use that instead. */ - if(data) { - convbuf = malloc(insize); - if(!convbuf) { - free(output); - return 0; - } - memcpy(convbuf, indata, insize); - if(CURLE_OK != Curl_convert_to_network(data, convbuf, insize)) { - free(convbuf); - free(output); - return 0; - } - indata = convbuf; /* switch to the converted buffer */ - } -#else - (void)data; -#endif + if(Curl_convert_clone(data, indata, insize, &convbuf)) + return 0; + + if(convbuf) + indata = (char *)convbuf; while(insize > 0) { for (i = inputparts = 0; i < 3; i++) { @@ -229,10 +214,9 @@ size_t Curl_base64_encode(struct SessionHandle *data, *output=0; *outptr = base64data; /* make it return the actual data memory */ -#ifdef CURL_DOES_CONVERSIONS - if(data) + if(convbuf) free(convbuf); -#endif + return strlen(base64data); /* return the length of the new data */ } /* ---- End of Base64 Encoding ---- */ |