Commit 96e051d2 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

graph: fix invalid read

Reported by Florian Renkin.

* spot/graph/graph.hh (sort_edges_of): Fix invalid read when sorting a
state without successor.  Seen on core/tgbagraph.test.
parent 968ef0f7
// -*- coding: utf-8 -*-
// Copyright (C) 2014-2018, 2020, 2021 Laboratoire de Recherche et
// Copyright (C) 2014-2018, 2020-2022 Laboratoire de Recherche et
// Développement de l'Epita.
//
// This file is part of Spot, a model checking library.
......@@ -1243,14 +1243,19 @@ namespace spot
//dump_storage(std::cerr);
auto pi = [&](unsigned t1, unsigned t2)
{return p(edges_[t1], edges_[t2]); };
// Sort the outgoing edges of each selected state according
// to predicate p. Do that in place.
std::vector<unsigned> sort_idx_;
for (unsigned i = 0; i < num_states(); ++i)
unsigned ns = num_states();
for (unsigned i = 0; i < ns; ++i)
{
if (to_sort_ptr && !(*to_sort_ptr)[i])
continue;
sort_idx_.clear();
unsigned t = states_[i].succ;
if (t == 0)
continue;
sort_idx_.clear();
do
{
sort_idx_.push_back(t);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment