]> The Tcpdump Group git mirrors - libpcap/commitdiff
Plug memory-leak 912/head
authorGisle Vanem <[email protected]>
Tue, 25 Feb 2020 09:04:21 +0000 (10:04 +0100)
committerGitHub <[email protected]>
Tue, 25 Feb 2020 09:04:21 +0000 (10:04 +0100)
If the '-i' option is not used, the strdup() memory was not freed.

testprogs/opentest.c

index 3c83a59824cd287dadeffa9dc0ad19ffac4d07b7..a441dda1268f7a0a54fc13939537d59f8960c7db 100644 (file)
@@ -81,7 +81,7 @@ main(int argc, char **argv)
                switch (op) {
 
                case 'i':
-                       device = optarg;
+                       device = strdup(optarg);
                        break;
 
                case 'I':
@@ -192,6 +192,7 @@ main(int argc, char **argv)
                else
                        printf("%s opened successfully\n", device);
        }
+       free(device);
        pcap_close(pd);
        exit(status < 0 ? 1 : 0);
 }