From aec64ffaa1e9b65983223a9a02c67e0880ec83d2 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sun, 6 Feb 2022 23:46:54 +0000 Subject: [PATCH] Use vector::at() when the index may not exist To avoid invoking undefined behaviour. --- src/api/sorting/group_sort.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/sorting/group_sort.cpp b/src/api/sorting/group_sort.cpp index 192caab0..b72b5934 100644 --- a/src/api/sorting/group_sort.cpp +++ b/src/api/sorting/group_sort.cpp @@ -206,7 +206,9 @@ GetTransitiveAfterGroups(const std::vector& masterlistGroups, // Create a color map. std::vector colorVec(boost::num_vertices(graph)); auto colorMap = boost::make_iterator_property_map( - colorVec.begin(), boost::get(boost::vertex_index, graph), colorVec[0]); + colorVec.begin(), + boost::get(boost::vertex_index, graph), + colorVec.at(0)); boost::depth_first_visit(graph, vertex, afterGroupsVisitor, colorMap); transitiveAfterGroups[graph[vertex]] = visitedGroups;