Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. //This LOOKED like it worked but failed when trying to free()
  2. int *ptr = (int *) malloc(sizeof(int));
  3. int x = 42;
  4. ptr = &x;
  5. free(ptr);
  6.  
  7. //This is what I meant to do in the first place
  8. int *ptr = (int *) malloc(sizeof(int));
  9. int x = 42;
  10. *ptr = x;
  11. free(ptr);
  12.  
  13.  
  14.