prevent segmentation fault after throwing an exception.

object has been freed in some cases. this comit prevents that segv.