Since you are calling free on a pointer that was NOT allocated by malloc, the behavior is undefined.