fixed some possible glibc errors on freeing non-allocated pointers