c – double free or corruption (fasttop)
The problem is here:
Basically, when you free temp2, you free first, not the memory allocated here:
, which remains a memory leak, because after the assignment it cant be freed anymore.
Also, your code has probably some more problems (one is that you shouldnt use
fflush on an input stream), but without some more details, its impossible to tell.