fix the bug of pointer may be NULL.