Fix null pointer dereference when deleting attributes