From 904cfb27fab9239086d9550290b6a0cc93ed0f58 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 22 Dec 2017 17:23:10 +0100 Subject: [PATCH] scc_info: detect incorrect initial state * spot/twaalgos/sccinfo.cc: Here. * tests/python/sccinfo.py: Test it. --- spot/twaalgos/sccinfo.cc | 5 +++++ tests/python/sccinfo.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/spot/twaalgos/sccinfo.cc b/spot/twaalgos/sccinfo.cc index e610fa795..ca0354279 100644 --- a/spot/twaalgos/sccinfo.cc +++ b/spot/twaalgos/sccinfo.cc @@ -75,6 +75,11 @@ namespace spot options_(options) { unsigned n = aut->num_states(); + + if (initial_state != -1U && n <= initial_state) + throw std::runtime_error + ("scc_info: supplied initial state does not exist"); + sccof_.resize(n, -1U); if (!!(options & scc_info_options::TRACK_STATES_IF_FIN_USED) diff --git a/tests/python/sccinfo.py b/tests/python/sccinfo.py index 264a308f7..ddf5d69f6 100644 --- a/tests/python/sccinfo.py +++ b/tests/python/sccinfo.py @@ -22,6 +22,12 @@ import spot a = spot.translate('(Ga -> Gb) W c') +try: + si = spot.scc_info(a, 10) + exit(2) +except RuntimeError as e: + assert "initial state does not exist" in str(e) + si = spot.scc_info(a) n = si.scc_count() assert n == 4