Fixed an invalid pointer and crash