From 8d48ceca368f6fcda0343944252cc7e4ac0ee91c Mon Sep 17 00:00:00 2001 From: Michael Hackstein Date: Mon, 12 Sep 2016 16:45:29 +0200 Subject: [PATCH] Fixed undefined behaviour on Mac. An empty vector was popped. --- arangod/VocBase/PathEnumerator.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arangod/VocBase/PathEnumerator.cpp b/arangod/VocBase/PathEnumerator.cpp index 818b412121..00e333d1ae 100644 --- a/arangod/VocBase/PathEnumerator.cpp +++ b/arangod/VocBase/PathEnumerator.cpp @@ -53,6 +53,7 @@ bool DepthFirstEnumerator::next() { _edgeCursors.emplace(cursor); } } else { + TRI_ASSERT(!_enumeratedPath.edges.empty()); // This path is at the end. cut the last step _enumeratedPath.vertices.pop_back(); _enumeratedPath.edges.pop_back(); @@ -70,6 +71,7 @@ bool DepthFirstEnumerator::next() { _returnedEdges.emplace(_enumeratedPath.edges.back()); } else { _traverser->_filteredPaths++; + TRI_ASSERT(!_enumeratedPath.edges.empty()); _enumeratedPath.edges.pop_back(); continue; } @@ -79,6 +81,7 @@ bool DepthFirstEnumerator::next() { _enumeratedPath.edges.size() - 1, cursorId)) { // This edge does not pass the filtering + TRI_ASSERT(!_enumeratedPath.edges.empty()); _enumeratedPath.edges.pop_back(); continue; } @@ -98,6 +101,7 @@ bool DepthFirstEnumerator::next() { if (!foundOnce) { // We found it and it was not the last element (expected) // This edge is allready on the path + TRI_ASSERT(!_enumeratedPath.edges.empty()); _enumeratedPath.edges.pop_back(); continue; } @@ -123,6 +127,7 @@ bool DepthFirstEnumerator::next() { if (!foundOnce) { // We found it and it was not the last element (expected) // This vertex is allready on the path + TRI_ASSERT(!_enumeratedPath.edges.empty()); _enumeratedPath.vertices.pop_back(); _enumeratedPath.edges.pop_back(); continue; @@ -136,13 +141,16 @@ bool DepthFirstEnumerator::next() { return true; } // Vertex Invalid. Revoke edge + TRI_ASSERT(!_enumeratedPath.edges.empty()); _enumeratedPath.edges.pop_back(); continue; } else { // cursor is empty. _edgeCursors.pop(); - _enumeratedPath.edges.pop_back(); - _enumeratedPath.vertices.pop_back(); + if (!_enumeratedPath.edges.empty()) { + _enumeratedPath.edges.pop_back(); + _enumeratedPath.vertices.pop_back(); + } } } if (_edgeCursors.empty()) {