'pkt'
函数后释放缓冲区时出现分段错误sendto()
u_char* create_pkt(u_char* pkt)
{
....
pkt = (u_char *)malloc(40);
...
return pkt
}
int main()
{
....
u_char* pkt;
create_pkt(pkt);
if (sendto(sd, pkt, 40, 0, (struct sockaddr *)&sin, sizeof(struct sockaddr)) < 0)
free(pkt);
}
调试信息显示:
Program received signal SIGSEGV, Segmentation fault.
0x0000003897482864 in __GI___libc_free (mem=0x7fffffffe010) at malloc.c:2986
这有什么问题?谢谢!
2986 ar_ptr = arena_for_chunk(p);
2986 ar_ptr = arena_for_chunk(p);