From 01549dfdea0bd11c33d0f5fea97e056647ca4210 Mon Sep 17 00:00:00 2001 From: TimQu Date: Tue, 31 Jul 2018 16:41:23 +0200 Subject: [PATCH] fixed segfaults when lifting transient destination assignments to the edge --- src/storm/storage/jani/TemplateEdge.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/storm/storage/jani/TemplateEdge.cpp b/src/storm/storage/jani/TemplateEdge.cpp index 89d56a0d3..6e5af6695 100644 --- a/src/storm/storage/jani/TemplateEdge.cpp +++ b/src/storm/storage/jani/TemplateEdge.cpp @@ -81,6 +81,8 @@ namespace storm { if (!destinations.empty()) { auto const& destination = *destinations.begin(); + std::vector> assignmentsToLift; + for (auto const& assignment : destination.getOrderedAssignments().getTransientAssignments()) { // Check if we can lift the assignment to the edge. bool canBeLifted = true; @@ -91,12 +93,18 @@ namespace storm { } } - // If so, remove the assignment from all destinations. if (canBeLifted) { - this->addTransientAssignment(assignment); - for (auto& destination : destinations) { - destination.removeAssignment(assignment); - } + // Do not remove the assignment now, as we currently iterate over them. + // Also we need to make a copy of the assignment since we are about to delete it + assignmentsToLift.push_back(std::make_shared(assignment)); + } + } + + // now actually lift the assignments + for (auto const& assignment : assignmentsToLift) { + this->addTransientAssignment(*assignment); + for (auto& destination : destinations) { + destination.removeAssignment(*assignment); } } }