Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
tcpdump: plug a memory leak.
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit 9904bbb)
  • Loading branch information
guyharris authored and fxlb committed Oct 5, 2023
1 parent 999e772 commit ba2cc21
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tcpdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -2654,6 +2654,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));
}
Expand Down

0 comments on commit ba2cc21

Please sign in to comment.