]> The Tcpdump Group git mirrors - tcpdump/commitdiff
tcpdump: plug a memory leak.
authorGuy Harris <[email protected]>
Sun, 5 Feb 2023 20:12:22 +0000 (12:12 -0800)
committerGuy Harris <[email protected]>
Sun, 5 Feb 2023 20:12:22 +0000 (12:12 -0800)
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.

tcpdump.c

index 08e038963ec02920bc42b3e2bf88bc8f98dc5fd8..7538a49c3ca2944ccfcdaf9aa32fe221622a8946 100644 (file)
--- 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));
                                }