From 2a3c7fb8c1a4b60bab7300eaf552f6ce15aebe52 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Tue, 7 Mar 2017 21:42:03 +0100 Subject: [PATCH] fix access deleted memory in state elimination --- .../src/automaton/convert/ToRegExpStateElimination.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/alib2algo/src/automaton/convert/ToRegExpStateElimination.cpp b/alib2algo/src/automaton/convert/ToRegExpStateElimination.cpp index de830f19cf..4620ee7b60 100644 --- a/alib2algo/src/automaton/convert/ToRegExpStateElimination.cpp +++ b/alib2algo/src/automaton/convert/ToRegExpStateElimination.cpp @@ -101,16 +101,16 @@ void ToRegExpStateElimination::extendExtendedNFA(automaton::ExtendedNFA < > & au if(automaton.getFinalStates().size() > 1) { DefaultStateType f = common::createUnique(label::FinalStateLabel::instance < DefaultStateType > ( ), automaton.getStates()); - automaton.addState(f); + automaton.addState ( f ); for(const auto &state : automaton.getFinalStates() ) { regexp::UnboundedRegExpStructure < DefaultSymbolType > regexp { regexp::UnboundedRegExpEpsilon < DefaultSymbolType > () }; automaton.addTransition(state, regexp, f); - - automaton.removeFinalState(state); } - automaton.addFinalState(f); + std::set < DefaultStateType > newFinalStates; + newFinalStates.insert ( f ); + automaton.setFinalStates ( newFinalStates ); } } -- GitLab