summaryrefslogtreecommitdiff
path: root/libquadmath
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2011-02-28 20:31:46 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2011-02-28 20:31:46 +0000
commit8847f6dc6ec8424e3877406f77669301665cb55f (patch)
tree22368093cbef6b62388b5074c8ebcb67297572fc /libquadmath
parent875ffd1d934c038e3651f6d67b9a37a5c8a809f8 (diff)
downloadgcc-8847f6dc6ec8424e3877406f77669301665cb55f.tar.gz
* printf/quadmath-printf.c (quadmath_snprintf): Make sure
that for size > 0 str is always zero terminated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170572 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libquadmath')
-rw-r--r--libquadmath/ChangeLog5
-rw-r--r--libquadmath/printf/quadmath-printf.c4
2 files changed, 7 insertions, 2 deletions
diff --git a/libquadmath/ChangeLog b/libquadmath/ChangeLog
index 71fbc2f547b..cc4bf882d8b 100644
--- a/libquadmath/ChangeLog
+++ b/libquadmath/ChangeLog
@@ -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
diff --git a/libquadmath/printf/quadmath-printf.c b/libquadmath/printf/quadmath-printf.c
index 750dc246fcc..b70f432cce0 100644
--- a/libquadmath/printf/quadmath-printf.c
+++ b/libquadmath/printf/quadmath-printf.c
@@ -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;