You might be freeing something which is already freed or one of the other usual suspects when doing C memory management.
If it's a C++ program, consider using new/delete instead of malloc/free, and do not
mix them up!
The glibc error message you got isn't very helpful on it's own. valgrind
might be able to help you pin down your error. If you fix it, don't forget to post here with some details and how you found the bug!