Another fix to snprintf().
authorBruno Haible <bruno@clisp.org>
Fri, 1 Oct 2004 13:27:20 +0000 (13:27 +0000)
committerBruno Haible <bruno@clisp.org>
Fri, 1 Oct 2004 13:27:20 +0000 (13:27 +0000)
lib/ChangeLog
lib/snprintf.c

index a701b151fb77f5dd9c834b7c3d23e2c7b743981e..7d2c82872e1e5e9b121ae2b6c81168f3cc3cbb0f 100644 (file)
@@ -1,3 +1,7 @@
+2004-10-01  Simon Josefsson  <jas@extundo.com>
+
+       * snprintf.c (snprintf): Handle size==0.
+
 2004-10-01  Simon Josefsson  <jas@extundo.com>
             Bruno Haible  <bruno@clisp.org>
 
index 92c265289a3730865150acb7c9781092b9f555cf..c23d7e14a39d92b42953128c060ef6f6835b9114 100644 (file)
@@ -55,7 +55,7 @@ snprintf (char *str, size_t size, const char *format, ...)
   if (!output)
     return -1;
 
-  if (str)
+  if (str && size > 0)
     {
       memcpy (str, output, MIN (len + 1, size));
       str[size - 1] = '\0';