]> The Tcpdump Group git mirrors - libpcap/commitdiff
Avoid calling free() on known-null pointer 1073/head
authorDaniel Miller <[email protected]>
Fri, 10 Dec 2021 17:27:30 +0000 (11:27 -0600)
committerDaniel Miller <[email protected]>
Fri, 10 Dec 2021 17:27:30 +0000 (11:27 -0600)
Standards all say free(NULL) is a safe no-op, but since we *know* fp
is NULL here because of the condition above, there's no need to risk it.

optimize.c

index 604e35e8852801a92f6d84692f028856381971bb..6fefeada0ae019d4f991549e6208c33b4c565fbf 100644 (file)
@@ -2899,7 +2899,6 @@ icode_to_fcode(struct icode *ic, struct block *root, u_int *lenp,
            if (fp == NULL) {
                (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
                    "malloc");
-               free(fp);
                return NULL;
            }
            memset((char *)fp, 0, sizeof(*fp) * n);