]> sjero.net Git - wget/blobdiff - src/utils.c
Minor formatting adjustments.
[wget] / src / utils.c
index 3c873d0e88df692d699774e613bf2534a4e85a0e..f4e56d82af72d69c17120cac6728930259571767 100644 (file)
@@ -178,7 +178,8 @@ aprintf (const char *fmt, ...)
   ret = vasprintf (&str, fmt, args);
   va_end (args);
   if (ret < 0 && errno == ENOMEM)
-    memfatal ("aprintf", UNKNOWN_ATTEMPTED_SIZE);  /* for consistency with xmalloc/xrealloc */
+    memfatal ("aprintf", UNKNOWN_ATTEMPTED_SIZE);  /* for consistency
+                                                      with xmalloc/xrealloc */
   else if (ret < 0)
     return NULL;
   return str;
@@ -208,15 +209,20 @@ aprintf (const char *fmt, ...)
       /* Else try again with a larger buffer. */
       if (n > -1)               /* C99 */
         size = n + 1;           /* precisely what is needed */
+      else if (size >= FMT_MAX_LENGTH)  /* We have a huge buffer, */
+        {                               /* maybe we have some wrong
+                                           format string? */
+          logprintf (LOG_ALWAYS, 
+                     _("%s: aprintf: text buffer is too big (%ld bytes), "
+                       "aborting.\n"),
+                     exec_name, size);  /* printout a log message */
+          abort ();                     /* and abort... */
+        }
       else
         {
-          if (size >= FMT_MAX_LENGTH)  /* We have a huge buffer, */
-            {                          /* maybe we have some wrong format string? */
-              free (str);              /* In this case we must free already allocated memory, */
-              return NULL;             /* and return NULL pointer... */
-            }
-                                       /* else, we continue to grow our buffer. */
-          size <<= 1;                  /* twice the old size */
+          /* else, we continue to grow our
+           * buffer: Twice the old size. */
+          size <<= 1;
         }
       str = xrealloc (str, size);
     }