Harden against null-pointer crashes