After a very long time, I finally managed to find out why my version of recover.c only managed to recover 1 image (recover.c only recovers 1 image)

Anyway, now I face a new problem. What I've attempted so far for recover.c only recovers 2 complete images (I can see the actual image when I click on it which was pretty cool) and a 3rd image that says "error interpreting JPEG image file: (improper call to JPEG library in state 201)". That's it. Only 3 images. On top of that, when I run ./recover I get this message in the terminal window: enter image description here

Here's what I've come up with so far: https://gist.github.com/ehahehah/e6d579dcb08649a4d65b

Anybody knows what double free or corruption means?

P.S. I don't know if I should combine this question with my original question

  • Why do you have two FILE* outside the loop?
    – Anfernee
    Sep 27, 2014 at 21:30
  • Because in the earlier versions of the code, gist.github.com/ehahehah/4b4038f7da99ab484b86 someone pointed out to me that when I declare the FILE* again inside my if condition it only exists within the scope of the if condition and once the if statement has executed, I would lose track of the FILE* pointer
    – user1742
    Sep 28, 2014 at 15:41
  • Ahh, I get it now. I forgot that there's a pointer for the file input. Its right.
    – Anfernee
    Sep 29, 2014 at 22:13

1 Answer 1


The two common reasons for that error message are
1) passing the same address to free twice
2) overrunning an allocated area before passing its address to free.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .