aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2018-04-28 12:02:43 +0100
committerSimon Tatham <anakin@pobox.com>2018-04-28 12:02:43 +0100
commite53c097fb742ac1ec61c70e64380190c067b59d9 (patch)
tree3b94d9b0e695f4ec818808792f78d3593cfbdb30
parenta1663d6650053eee5e43a1267a05578a920521da (diff)
downloadpuzzles-e53c097fb742ac1ec61c70e64380190c067b59d9.zip
puzzles-e53c097fb742ac1ec61c70e64380190c067b59d9.tar.gz
puzzles-e53c097fb742ac1ec61c70e64380190c067b59d9.tar.bz2
puzzles-e53c097fb742ac1ec61c70e64380190c067b59d9.tar.xz
latin.c: remove a rogue array overrun.
Oops! This was left over from an early development version of commits 4408476b7 and 000ebc507, in which I initially arranged for each adjacency list to be terminated with the sentinel value -1 instead of separately storing an array of the lists' lengths. I later changed the representation to make randomising the algorithm easier (it's much easier to shuffle an array uniformly at random if you _don't_ have to faff endlessly to work out its length). But this write of a no-longer- needed sentinel value in the client code must have survived the rewrite by mistake, and also somehow evaded all my pre-commit testing with valgrind and asan. A user reported that the Towers Javascript version was crashing on startup, and I think this is the cause, because it seems to fix it for me.
-rw-r--r--latin.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/latin.c b/latin.c
index 710be2c..6e80545 100644
--- a/latin.c
+++ b/latin.c
@@ -1172,7 +1172,6 @@ digit *latin_generate(int o, random_state *rs)
if (adj[k])
*p++ = k;
adjsizes[j] = p - adjlists[j];
- *p = -1;
}
/*