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.
This commit is contained in:
parent
cd2e527526
commit
6cf807da6e
4 changed files with 10 additions and 1 deletions
1
NEWS
1
NEWS
|
|
@ -32,6 +32,7 @@ New in spot 1.99.4a (not yet released)
|
||||||
* Fix compilation of bench/stutter/
|
* Fix compilation of bench/stutter/
|
||||||
* Handle saturation of formula reference counts.
|
* Handle saturation of formula reference counts.
|
||||||
* Fix typo in the Python code for the CGI server.
|
* 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)
|
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);
|
opt_states = parse_range(arg);
|
||||||
if (opt_states.min > opt_states.max)
|
if (opt_states.min > opt_states.max)
|
||||||
std::swap(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;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
opt_state_acc = true;
|
opt_state_acc = true;
|
||||||
|
|
@ -308,6 +310,8 @@ main(int argc, char** argv)
|
||||||
if (opt_acc_sets.min == -1)
|
if (opt_acc_sets.min == -1)
|
||||||
opt_acc_sets.min = 0;
|
opt_acc_sets.min = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
spot::srand(opt_seed);
|
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
|
$randaut -S -A'parity min even 0..3' -q -n10 --colored 2 2>stderr && exit 1
|
||||||
grep 'randaut: --colored requires' stderr
|
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,
|
unsigned n_accs, float a, float t,
|
||||||
bool deterministic, bool state_acc, bool colored)
|
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);
|
auto res = make_twa_graph(dict);
|
||||||
if (deterministic)
|
if (deterministic)
|
||||||
res->prop_deterministic();
|
res->prop_deterministic();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue