]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: memprof: avoid a small memory leak in "show profiling"
authorWilly Tarreau <w@1wt.eu>
Wed, 11 Mar 2026 14:14:43 +0000 (15:14 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 12 Mar 2026 17:06:37 +0000 (18:06 +0100)
In 3.1, per-DSO statistics were added to the memprofile output by
commit 401fb0e87a ("MINOR: activity/memprofile: show per-DSO stats").
However an strdup() is performed there on the .info field, that is
never freed when leaving the function. Let's do it each time we leave
it. Ironically, this was found thanks to "show profiling" showing
itself as an unbalanced caller of strdup().

This needs to be backported to 3.0 since that commit was backported
there.

src/activity.c

index 0c1ce9e6bffc40ac88e946160c079a55778cbfcf..fe6a5916cbd4a9b0fb9065bdd39bc3827150d82a 100644 (file)
@@ -1309,6 +1309,10 @@ static int cli_io_handler_show_profiling(struct appctx *appctx)
                      tot_alloc_calls - tot_free_calls,
                      tot_alloc_bytes - tot_free_bytes);
 
+       /* release optional buffer name */
+       for (i = 0; i < max; i++)
+               ha_free(&tmp_memstats[i].info);
+
        if (applet_putchk(appctx, &trash) == -1)
                return 0;