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 a701b15..7d2c828 100644 (file)
@@ -1,4 +1,8 @@
 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>
 
        * snprintf.c: Include <stdarg.h>, <stdlib.h>, <string.h>.
index 92c2652..c23d7e1 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';