[DTrace-devel] [PATCH 7/8] probe: fix memory leaks
Nick Alcock
nick.alcock at oracle.com
Thu Apr 4 20:01:52 UTC 2024
On 3 Apr 2024, Kris Van Hees via DTrace-devel said:
> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Nick Alcock <nick.alcock at oracle.com>
> @@ -962,6 +962,9 @@ dt_probe_args_info(dtrace_hdl_t *dtp, dt_probe_t *prp)
> prp->mapping[i] = argv[i].mapping;
> prp->argv[i] = dtt;
> prp->xargv[i]->dn_flags |= argv[i].flags;
> +
> + free((char *)argv[i].native);
> + free((char *)argv[i].xlate);
> }
>
> dt_free(dtp, argv);
... but there are plenty of return paths further up in this function
which just outright leak (like after the dt_probe_alloc_args failure
path) or which don't allow for the possibility of argv being allocated
if argc is 0 (sure, it's unlikely, but are you *sure* it'll never get
modified to stick a single "" in there or something? it seems more
robust to just goto a freeing path in all these cases).
--
NULL && (void)
More information about the DTrace-devel
mailing list