1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 1: typedef struct T_ { 2: char a; 3: char b; 4: }T; 5: int main() 6: { 7: T a,b; 8: char x; 9: a.a = 'a'; 10: a.b = 'b'; 11: b.a = x; 12: if(b.a ==10) 13: memcpy(&b,&a, sizeof(T)); 14: return 0; 15: } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | Dr. Memory results for pid 24399, … Error #1: UNINITIALIZED READ: reading register al # 0 t!main [/home/DrMem/uninit.c:16] # 1 libc.so.6<nosyms>!? # 2 t!_start Note: elapsed time = 0:00:00.111 in thread 24399 Note: instruction: cmp %al $0x0a ======================================================== FINAL SUMMARY: Grouping errors that may be the same or related: Group 1: Group 2: 1 DUPLICATE ERROR COUNTS: SUPPRESSIONS USED: ERRORS FOUND: 0 unique, 0 total unaddressable access(es) 1 unique, 1 total uninitialized access(es) 0 unique, 0 total invalid heap argument(s) 0 unique, 0 total warning(s) 0 unique, 0 total, 0 byte(s) of leak(s) 0 unique, 0 total, 0 byte(s) of possible leak(s) ERRORS IGNORED: 0 still-reachable allocation(s) |
1 2 3 4 5 6 7 8 9 | //invalidArg.cpp 4: int main() 5: { 6: char * ptr = NULL; 7: ptr = new char; 8: free(ptr); 9: free(ptr); 10: return 0; 11: } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | Error #1: INVALID HEAP ARGUMENT: allocated with operator new, freed with free # 0 t!main [/home/DrMem/invalidArg.cpp:8] # 1 libc.so.6<nosyms>!? # 2 t!_start Note: elapsed time = 0:00:00.165 in thread 27804 Note: memory was allocated here: Note: # 0 libstdc++.so.6<nosyms>!? Note: # 1 t!main [/home/DrMem/invalidArg.cpp:7] Note: # 2 libc.so.6<nosyms>!? Error #2: INVALID HEAP ARGUMENT to free() 0x0804a018 # 0 t!main [/homeDrMem/invalidArg.cpp:9] # 1 libc.so.6<nosyms>!? # 2 t!_start Note: elapsed time = 0:00:00.167 in thread 27804 Note: memory was previously freed |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |