Imported Upstream version 7.59.0
[platform/upstream/curl.git] / src / tool_msgs.c
index 1454903..91d62ec 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2015, 2017, 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
@@ -38,13 +38,16 @@ static void voutf(struct GlobalConfig *config,
                   const char *fmt,
                   va_list ap)
 {
-  size_t width = (79 - (int)strlen(prefix));
+  size_t width = (79 - strlen(prefix));
   if(!config->mute) {
     size_t len;
     char *ptr;
-    char print_buffer[256];
+    char *print_buffer;
 
-    len = vsnprintf(print_buffer, sizeof(print_buffer), fmt, ap);
+    print_buffer = curlx_mvaprintf(fmt, ap);
+    if(!print_buffer)
+      return;
+    len = strlen(print_buffer);
 
     ptr = print_buffer;
     while(len > 0) {
@@ -63,7 +66,7 @@ static void voutf(struct GlobalConfig *config,
 
         (void)fwrite(ptr, cut + 1, 1, config->errors);
         fputs("\n", config->errors);
-        ptr += cut+1; /* skip the space too */
+        ptr += cut + 1; /* skip the space too */
         len -= cut;
       }
       else {
@@ -71,6 +74,7 @@ static void voutf(struct GlobalConfig *config,
         len = 0;
       }
     }
+    curl_free(print_buffer);
   }
 }