Forum Discussion
Altera_Forum
Honored Contributor
13 years agoThat last free in your function should be wrapped with an if statement guarding it from trying to free an unallocated pointer. I suspect you are running into a stack and heap collision like DSL warned you of.
A common way for detecting a stack and heap collision is to fill your memory with some known pattern (you pick), then populate it with your code, run the code, then take a look at the memory after to see if your pattern is still around. If the pattern is gone then there was most likely a stack + heap collision.