check null ptr

Signed-off-by: lizhenghn123 <lizhenghn@gmail.com>