Faulty null check on dereferenced object