diff --git a/NEWS b/NEWS index 08f1c74a3..a87401652 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,7 @@ New in spot 1.99.4a (not yet released) * Fix compilation of bench/stutter/ * Handle saturation of formula reference counts. * Fix typo in the Python code for the CGI server. + * "randaut -Q0 1" used to segfault. New in spot 1.99.4 (2015-10-01) diff --git a/src/bin/randaut.cc b/src/bin/randaut.cc index f55ab6122..d7874ade1 100644 --- a/src/bin/randaut.cc +++ b/src/bin/randaut.cc @@ -221,6 +221,8 @@ parse_opt(int key, char* arg, struct argp_state* as) opt_states = parse_range(arg); if (opt_states.min > opt_states.max) std::swap(opt_states.min, opt_states.max); + if (opt_states.min == 0) + error(1, 0, "cannot build an automaton with 0 states"); break; case 'S': opt_state_acc = true; @@ -308,6 +310,8 @@ main(int argc, char** argv) if (opt_acc_sets.min == -1) opt_acc_sets.min = 0; + + try { spot::srand(opt_seed); diff --git a/src/tests/randaut.test b/src/tests/randaut.test index b745ba7aa..2b5e3969f 100755 --- a/src/tests/randaut.test +++ b/src/tests/randaut.test @@ -144,4 +144,7 @@ grep 'randaut: --colored requires' stderr $randaut -S -A'parity min even 0..3' -q -n10 --colored 2 2>stderr && exit 1 grep 'randaut: --colored requires' stderr +$randaut -Q0 1 2>stderr && exit 1 +grep '0 states' stderr + : diff --git a/src/twaalgos/randomgraph.cc b/src/twaalgos/randomgraph.cc index 71f5354b9..41e3d95fb 100644 --- a/src/twaalgos/randomgraph.cc +++ b/src/twaalgos/randomgraph.cc @@ -126,7 +126,8 @@ namespace spot unsigned n_accs, float a, float t, bool deterministic, bool state_acc, bool colored) { - assert(n > 0); + if (n <= 0) + throw std::invalid_argument("random_graph() requires n>0 states"); auto res = make_twa_graph(dict); if (deterministic) res->prop_deterministic();