Double free when use pcap_close and fclose simultaneously

40 Views Asked by At
FILE* file = fopen(some file)

pcap_t* pd = pcap_fopen_offline(file)

pcap_close(pd)

fclose(file)

This code occurs double free error.

Could you explain about this happening?

My Guess is that pd and file pointers are sharing some datas.

1

There are 1 best solutions below

0
David Schwartz On BEST ANSWER

As the documentation says, the pcap_close function closes the files associated with the pcap_t structure passed to it. Closing the file again with fclose is an error.