summaryrefslogtreecommitdiff
path: root/lib/vasnprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vasnprintf.c')
-rw-r--r--lib/vasnprintf.c5
1 files changed, 3 insertions, 2 deletions
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':