From ee6e2f1bae27cb24806ef772f4a4ad17ed739f72 Mon Sep 17 00:00:00 2001 From: Robin Jadoul <robin.jadoul@gmail.com> Date: Tue, 10 May 2016 16:25:03 +0200 Subject: [PATCH] Fix segfault in ENFA::eClose --- src/automata.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/automata.cpp b/src/automata.cpp index 7896118..57a08e5 100644 --- a/src/automata.cpp +++ b/src/automata.cpp @@ -1,5 +1,6 @@ #include "Lexesis/automata.h" +#include <cassert> #include <algorithm> #include <climits> #include <queue> @@ -103,8 +104,9 @@ namespace lxs { while(!statequeue.empty()) { auto state = statequeue.front(); statequeue.pop(); - const auto& newStates = epsilonTransitions.find(state)->second; - for(auto newstate: newStates) { + const auto newStatesIt = epsilonTransitions.find(state); + if (newStatesIt == epsilonTransitions.end()) continue; + for(const auto& newstate: newStatesIt->second) { if(states.find(newstate) == states.end()) { states.insert(newstate); statequeue.push(newstate);