From: Denis Ovsienko Date: Thu, 17 Apr 2025 13:26:51 +0000 (+0100) Subject: Plug memory leaks from pcap_nametoaddrinfo() w/o INET6. X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/5204c1b30b42f56921cc0313d1c6b9577f3916ff Plug memory leaks from pcap_nametoaddrinfo() w/o INET6. struct _compiler_state includes the member ai regardless of INET6; gen_scode() assigns it in two instances regardless of INET6 and in one instance if INET6 is not defined. Therefore the initialization and the conditional memory deallocation should not be specific to INET6. --- diff --git a/gencode.c b/gencode.c index eed4863c..b593079d 100644 --- a/gencode.c +++ b/gencode.c @@ -1146,9 +1146,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program, initchunks(&cstate); cstate.no_optimize = 0; -#ifdef INET6 cstate.ai = NULL; -#endif cstate.e = NULL; cstate.ic.root = NULL; cstate.ic.cur_mark = 0; @@ -1185,10 +1183,8 @@ pcap_compile(pcap_t *p, struct bpf_program *program, goto quit; } if (pcap_parse(scanner, &cstate) != 0) { -#ifdef INET6 if (cstate.ai != NULL) freeaddrinfo(cstate.ai); -#endif if (cstate.e != NULL) free(cstate.e); rc = PCAP_ERROR;