Skip to content

Commit

Permalink
Fix memleak in the recently added benchmarks (google#305)
Browse files Browse the repository at this point in the history
Remove dupe call to pcap_datalink(). Add free() to pathname in delete_file(). Some spacing.
  • Loading branch information
roachspray authored May 5, 2020
1 parent 76f90be commit 41aa9b4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions benchmarks/jasper-1.701.0/jasper_fuzz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ delete_file(const char *pathname)
if (ret == -1) {
warn("failed to delete \"%s\"", pathname);
}
free((void *)pathname);
return ret;
#endif
}
Expand Down
1 change: 1 addition & 0 deletions benchmarks/perl-5.21.7/perl_fuzz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ delete_file(const char *pathname)
if (ret == -1) {
warn("failed to delete \"%s\"", pathname);
}
free((void *)pathname);
return ret;
#endif
}
Expand Down
10 changes: 4 additions & 6 deletions benchmarks/tcpdump-4.9.0/tcpdump_fuzz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ delete_file(const char *pathname)
if (ret == -1) {
warn("failed to delete \"%s\"", pathname);
}
free((void *)pathname);
return ret;
#endif
}
Expand Down Expand Up @@ -159,18 +160,15 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
}

dlt = pcap_datalink(pd);
dlt = pcap_datalink(pd);
ndo->ndo_if_printer = get_if_printer(ndo, dlt);
ndo->ndo_if_printer = get_if_printer(ndo, dlt);
callback = print_packet;
pcap_userdata = (u_char *)ndo;
dlt_name = pcap_datalink_val_to_name(dlt);
if (dlt_name == NULL) {
fprintf(stderr, "reading from file %s, link-type %u\n", in, dlt);
} else {
fprintf(stderr,
"reading from file %s, link-type %s (%s)\n",
in, dlt_name,
pcap_datalink_val_to_description(dlt));
fprintf(stderr, "reading from file %s, link-type %s (%s)\n",in, dlt_name,
pcap_datalink_val_to_description(dlt));
}
status = pcap_loop(pd, 0, callback, pcap_userdata);
pcap_close(pd);
Expand Down

0 comments on commit 41aa9b4

Please sign in to comment.