Double free when use pcap_close and fclose simultaneously.

huangapple go评论56阅读模式
英文:

Double free when use pcap_close and fclose simultaneously

问题

这段代码出现了双重释放错误。

能否解释一下为什么会发生这种情况?

我猜测 pd 和 file 指针共享了一些数据。

英文:
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

得分: 1

根据文档,pcap_close 函数关闭与传递给它的 pcap_t 结构相关联的文件。再次使用 fclose 关闭文件是一个错误。

英文:

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.

huangapple
  • 本文由 发表于 2023年6月9日 10:26:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76436815.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定