aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--elf/dl-printf.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/elf/dl-printf.c b/elf/dl-printf.c
index 429d2e80c2..00c114002c 100644
--- a/elf/dl-printf.c
+++ b/elf/dl-printf.c
@@ -163,8 +163,11 @@ _dl_debug_vdprintf (int fd, int tag_p, const char *fmt, va_list arg)
/* We use alloca() to allocate the buffer with the most
pessimistic guess for the size. Using alloca() allows
having more than one integer formatting in a call. */
- char *buf = (char *) alloca (1 + 3 * sizeof (unsigned long int));
- char *endp = &buf[1 + 3 * sizeof (unsigned long int)];
+ int size = 1 + 3 * sizeof (unsigned long int);
+ if (width + 1 > size)
+ size = width + 1;
+ char *buf = (char *) alloca (size);
+ char *endp = &buf[size];
char *cp = _itoa (num, endp, *fmt == 'x' ? 16 : 10, 0);
/* Pad to the width the user specified. */