Protecting against potential NULL pointer dereference