正在加载图片...
检测非法内存地址访问 2 test2.c(~/calg/memchk)-gedit 一口× 文件()编辑(E)查看)搜索(S)工具(D文档(D)帮助H) 巴打开业保存台的撤消◆端岛鹤 test2.c× 1 #include <stdlib.h> 2 3 int main(void) 4 { 5 char *p malloc(10); 6 p[10]1;/write to illegal memory address*/ 7 free(p); 8 return EXIT_SUCCESS; 9 } ==3142==Copyright (C)2002-2012,and GNU GPL'd,by Julian Seward et al. ==3142==Using Valgrind-3.8.1 and LibVEX;rerun with -h for copyright info ==3142==Command:./test2 ==3142== -=3T42==Invalid write of size 1 -3142= at 0x8048414:main (test2.c:6) ==3142==Address 0x4027032-is-0-bytes after a block of size 10 alloc'd ==3142== at 0x40072B2:malloc (vg_replace_malloc.c:270) ==3142= by 0x8048408:main (test2.c:5) ==3142== ==3142== ==3142==HEAP SUMMARY: ==3142== in use at exit:0 bytes in 0 blocks ==3142== total heap usage:1 allocs,1 frees,10 bytes allocated ==3142== ==3142==All heap blocks were freed --no leaks are possible ==3142== ==3142==For counts of detected and suppressed errors,rerun with:-v 国终端Shell输出 C~跳格宽度:4~行6,列50 播入 9检测非法内存地址访问 9
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有