Fix dereference after null check