]> granicus.if.org Git - strace/commitdiff
2007-07-11 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Wed, 11 Jul 2007 07:23:40 +0000 (07:23 +0000)
committerRoland McGrath <roland@redhat.com>
Wed, 11 Jul 2007 07:23:40 +0000 (07:23 +0000)
* util.c (printstr): Fix size calculation for outstr allocation.

util.c

diff --git a/util.c b/util.c
index 1ca400f91d9dd985ccb91a579b0ba7760de82c86..55f80700b33450081ceca57e6d62f2c29c50f12c 100644 (file)
--- 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) {