fix possible dereference of NULL pointer