Revert "Imported Upstream version 7.44.0"
[platform/upstream/curl.git] / lib / base64.c
index 6b87eed..6b1eb7c 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
 /* Base64 encoding/decoding */
 
 #include "curl_setup.h"
-#include "curl_printf.h"
+
+#define _MPRINTF_REPLACE /* use our functions only */
+#include <curl/mprintf.h>
+
 #include "urldata.h" /* for the SessionHandle definition */
 #include "warnless.h"
 #include "curl_base64.h"
+#include "curl_memory.h"
 #include "non-ascii.h"
 
-/* The last #include files should be: */
-#include "curl_memory.h"
+/* include memdebug.h last */
 #include "memdebug.h"
 
 /* ---- Base64 Encoding/Decoding Table --- */
@@ -149,7 +152,7 @@ CURLcode Curl_base64_decode(const char *src,
   for(i = 0; i < numQuantums; i++) {
     size_t result = decodeQuantum(pos, src);
     if(!result) {
-      free(newstr);
+      Curl_safefree(newstr);
 
       return CURLE_BAD_CONTENT_ENCODING;
     }
@@ -252,7 +255,8 @@ static CURLcode base64_encode(const char *table64,
   *output = '\0';
   *outptr = base64data; /* return pointer to new data, allocated memory */
 
-  free(convbuf);
+  if(convbuf)
+    free(convbuf);
 
   *outlen = strlen(base64data); /* return the length of the new data */