mirko666

leak test

Jul 18th, 2024 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1.  
  2. # gcc leak.c -o leak -fsanitize=address -static-libasan
  3. # ./leak
  4.  
  5. string is: Hello world!
  6.  
  7. =================================================================
  8. ==19293==ERROR: LeakSanitizer: detected memory leaks
  9.  
  10. Direct leak of 100 byte(s) in 1 object(s) allocated from:
  11. #0 0x563f80c07c20 in malloc (/home/ansible/test/leak+0xcfc20)
  12. #1 0x563f80c43f31 in main (/home/ansible/test/leak+0x10bf31)
  13. #2 0x7f8fec9a109a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
  14.  
  15. SUMMARY: AddressSanitizer: 100 byte(s) leaked in 1 allocation(s).
  16.  
  17. # cat leak.c
  18.  
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <string.h>
  22.  
  23. int main(int argc, const char *argv[]) {
  24. char *s = malloc(100);
  25. strcpy(s, "Hello world!");
  26. printf("string is: %s\n", s);
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment