From: Roland McGrath Date: Wed, 11 Jul 2007 07:23:40 +0000 (+0000) Subject: 2007-07-11 Roland McGrath X-Git-Tag: v4.5.18~190 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=779c466c0fdb4a0e4039d5ed407d1e6f61c23437;p=strace 2007-07-11 Roland McGrath * util.c (printstr): Fix size calculation for outstr allocation. --- diff --git a/util.c b/util.c index 1ca400f9..55f80700 100644 --- a/util.c +++ b/util.c @@ -449,13 +449,14 @@ int len; } if (!str) { if ((str = malloc(max_strlen)) == NULL - || (outstr = malloc(2*max_strlen)) == NULL) { + || (outstr = malloc(4*max_strlen + + sizeof "\"\"...")) == NULL) { fprintf(stderr, "out of memory\n"); tprintf("%#lx", addr); return; } } - outend = outstr + max_strlen * 2 - 10; + outend = outstr + max_strlen * 4; if (len < 0) { n = max_strlen; if (umovestr(tcp, addr, n, (char *) str) < 0) {