From: Guy Harris Date: Sun, 5 Feb 2023 20:12:22 +0000 (-0800) Subject: tcpdump: plug a memory leak. X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/9904bbbd9ed020931d55ce6a4aed8a1dfc3d3841 tcpdump: plug a memory leak. If the -V flag is used, and not all files in the -V file have the same link-layer type, when the filter is recompiled for a new link-layer type, the old filter program is leaked. Free the old filter before compiling the new filter. --- diff --git a/tcpdump.c b/tcpdump.c index 08e03896..7538a49c 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -2711,6 +2711,8 @@ DIAG_ON_ASSIGN_ENUM */ dlt = new_dlt; ndo->ndo_if_printer = get_if_printer(dlt); + /* Free the old filter */ + pcap_freecode(&fcode); if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0) error("%s", pcap_geterr(pd)); }