Fix wrong NULL pointer check