quadmath-printf.c (quadmath_snprintf): Make sure that for size > 0 str is always...
authorJakub Jelinek <jakub@redhat.com>
Mon, 28 Feb 2011 20:31:46 +0000 (21:31 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 28 Feb 2011 20:31:46 +0000 (21:31 +0100)
* printf/quadmath-printf.c (quadmath_snprintf): Make sure
that for size > 0 str is always zero terminated.

From-SVN: r170572

libquadmath/ChangeLog
libquadmath/printf/quadmath-printf.c

index 71fbc2f547ba84266c2742992dce51154981cdec..cc4bf882d8b700bd74b3a04a6c9027733737f528 100644 (file)
@@ -1,3 +1,8 @@
+2011-02-28  Jakub Jelinek  <jakub@redhat.com>
+
+       * printf/quadmath-printf.c (quadmath_snprintf): Make sure
+       that for size > 0 str is always zero terminated.
+
 2011-02-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR bootstrap/47827
index 750dc246fcc885e0842041743d757a7ab109322c..b70f432cce02ca836acf3f1c55b2e0d150ce04ac 100644 (file)
@@ -256,7 +256,7 @@ quadmath_snprintf (char *str, size_t size, const char *format, ...)
 
   qfp.fp = NULL;
   qfp.str = str;
-  qfp.size = size;
+  qfp.size = size ? size - 1 : 0;
   qfp.len = 0;
   qfp.file_p = 0;
 
@@ -265,7 +265,7 @@ quadmath_snprintf (char *str, size_t size, const char *format, ...)
   else
     __quadmath_printf_fp (&qfp, &info, (const void *const *)&fpnum_addr2);
 
-  if (qfp.size)
+  if (size)
     *qfp.str = '\0';
 
   return qfp.len;