]> The Tcpdump Group git mirrors - libpcap/commitdiff
Plug memory leaks from pcap_nametoaddrinfo() w/o INET6.
authorDenis Ovsienko <[email protected]>
Thu, 17 Apr 2025 13:26:51 +0000 (14:26 +0100)
committerDenis Ovsienko <[email protected]>
Tue, 22 Apr 2025 20:09:53 +0000 (21:09 +0100)
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.

gencode.c

index eed4863cbb7189c5730d1fb5ddec4969295dfb3e..b593079da607b6785b4924073a1fff03fe0db69f 100644 (file)
--- 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;