]> granicus.if.org Git - strace/blobdiff - util.c
tests: check decoding of netlink smc_diag_msg attributes
[strace] / util.c
diff --git a/util.c b/util.c
index 0167e88193a6e9ca41bbcbbd4f8edb6254174dd6..2ccfe4fe32438199a43936872d8478c68010e305 100644 (file)
--- a/util.c
+++ b/util.c
@@ -759,10 +759,13 @@ printstr_ex(struct tcb *const tcp, const kernel_ulong_t addr,
        }
        /* Allocate static buffers if they are not allocated yet. */
        if (!str) {
-               unsigned int outstr_size = 4 * max_strlen + /*for quotes and NUL:*/ 3;
+               const unsigned int outstr_size =
+                       4 * max_strlen + /* for quotes and NUL */ 3;
+               /*
+                * We can assume that outstr_size / 4 == max_strlen
+                * since we have a guarantee that max_strlen <= -1U / 4.
+                */
 
-               if (outstr_size / 4 != max_strlen)
-                       die_out_of_memory();
                str = xmalloc(max_strlen + 1);
                outstr = xmalloc(outstr_size);
        }