Fix null dereference of pointers