Guest User

Double free

a guest
Aug 27th, 2022
924
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | Software | 0 0
  1. #include <stdio.h>
  2. #include <malloc.h>
  3. int main(){
  4.  
  5. char *a = (char*) malloc(10);
  6. char *b = (char*) malloc(10);
  7. char *c = (char*) malloc(10);
  8.  
  9. printf("a is at memory %p \n",a);
  10. printf("b is at memory %p \n",b);
  11. printf("c is at memory %p \n",c);
  12.  
  13. free(a);
  14. printf("Freeing a \n");
  15.  
  16.  
  17. free(b);
  18. printf("Freeing b  \n ");
  19.  
  20. free(c);
  21. printf("Freeing c \n");
  22. free(c);
  23. printf("Freeing c twice \n");
  24.  
  25.  
  26. return 0;
  27.  
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment