Commit 6cf807da authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

fix crash of randaut -Q0

* src/twaalgos/randomgraph.cc: Replace an assertion by an exception.
* src/bin/randaut.cc: Diagnose -Q0.
* src/tests/randaut.test: Test it.
* NEWS: Mention the bug.
parent cd2e5275
......@@ -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)
......
......@@ -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);
......
......@@ -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
:
......@@ -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();
......
Markdown is supported
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