From 4a3df704b6821ff889fdce81f41650563fb3604c Mon Sep 17 00:00:00 2001 From: Teon Banek Date: Wed, 24 Apr 2019 16:22:29 +0200 Subject: [PATCH] Fix iterator invalidation when appending to vector Reviewers: mtomic, mferencevic Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1979 --- tests/unit/bfs_common.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/unit/bfs_common.hpp b/tests/unit/bfs_common.hpp index b50ea55db..872a2defc 100644 --- a/tests/unit/bfs_common.hpp +++ b/tests/unit/bfs_common.hpp @@ -63,9 +63,10 @@ std::vector> GetEdgeList( for (auto &e : ret) std::swap(e.first, e.second); break; case query::EdgeAtom::Direction::BOTH: - std::transform( - ret.begin(), ret.end(), std::back_inserter(ret), - [](const auto &e) { return std::make_pair(e.second, e.first); }); + auto ret_copy = ret; + for (const auto &e : ret_copy) { + ret.emplace_back(e.second, e.first); + } break; } return ret;