Fix null pointer exception (Bug report #806)