fixed crashes trying to free() an automatically allocated char*