Fixed a serious bug, trying to free memory not located on the heap.