diff options
-rw-r--r-- | lib/ChangeLog | 6 | ||||
-rw-r--r-- | lib/vasnprintf.c | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog index 49c0e93c8..e1b4c7aac 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2007-03-20 Jim Meyering <jim@meyering.net> + + Fix a typo in the handling of %x and %X. + * vasnprintf.c (VASNPRINTF): When adding 2 to buffer length, + don't double it. + 2007-03-04 Jim Meyering <jim@meyering.net> * vasnprintf.c (VASNPRINTF): Add missing semicolon. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 8be7ac480..8a9ec9e93 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -415,8 +415,9 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar if (tmp_length < precision) tmp_length = precision; /* Add 2, to account for a leading sign or alternate form. */ - if (tmp_length <= SIZE_MAX / 2) - tmp_length *= 2; + tmp_length += 2; + if (tmp_length < 2) + goto out_of_memory; break; case 'f': case 'F': |