Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # gcc leak.c -o leak -fsanitize=address -static-libasan
- # ./leak
- string is: Hello world!
- =================================================================
- ==19293==ERROR: LeakSanitizer: detected memory leaks
- Direct leak of 100 byte(s) in 1 object(s) allocated from:
- #0 0x563f80c07c20 in malloc (/home/ansible/test/leak+0xcfc20)
- #1 0x563f80c43f31 in main (/home/ansible/test/leak+0x10bf31)
- #2 0x7f8fec9a109a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
- SUMMARY: AddressSanitizer: 100 byte(s) leaked in 1 allocation(s).
- # cat leak.c
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main(int argc, const char *argv[]) {
- char *s = malloc(100);
- strcpy(s, "Hello world!");
- printf("string is: %s\n", s);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment