Fix the null pointer dereference