当前位置: 技术问答>linux和unix
free出错
来源: 互联网 发布时间:2016-10-13
本文导语: typedef struct package_a { short int pid; short int plen; }package; package * buffer; buffer = (package *)malloc(sizeof(package)); bzero((char*)&buffer,sizeof(package)); free(bu...
typedef struct package_a
{
short int pid;
short int plen;
}package;
package * buffer;
buffer = (package *)malloc(sizeof(package));
bzero((char*)&buffer,sizeof(package));
free(buffer);
buffer = 0;
Program received signal SIGSEGV, Segmentation fault.
0x009099b4 in free () from /lib/libc.so.6
(gdb)
Single stepping until exit from function free,
which has no line number information.
[Stepped over thread exit]
[Thread 0xb7fc9b90 (LWP 4118) exited]
|
typedef struct package_a
{
short int pid;
short int plen;
}package;
package * buffer;
buffer = (package *)malloc(sizeof(package));
bzero((char*)buffer,sizeof(package));
free(buffer);
buffer = 0;
{
short int pid;
short int plen;
}package;
package * buffer;
buffer = (package *)malloc(sizeof(package));
bzero((char*)buffer,sizeof(package));
free(buffer);
buffer = 0;