summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-07-25 21:57:28 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-07-25 21:57:28 -0700
commit552b75c3572b11e37581c2c5ac359319af6941f5 (patch)
treeeb4097db6adbf45094e753bdbcc42d92f52a0749
parent0f5fbbe6f79823161ca3d921255dd0f234868e02 (diff)
downloadtxr-552b75c3572b11e37581c2c5ac359319af6941f5.tar.gz
txr-552b75c3572b11e37581c2c5ac359319af6941f5.tar.bz2
txr-552b75c3572b11e37581c2c5ac359319af6941f5.zip
hash: out of bound array access in hash-iter-peek.
* hash.c (hash_iter_peek): The loop here must be a top-of-test while loop, not a bottom-test do loop. In the chained hashing implementation, this was a do loop, but it also had a test with a break for the index.
-rw-r--r--hash.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/hash.c b/hash.c
index b24740ec..2c915540 100644
--- a/hash.c
+++ b/hash.c
@@ -1341,11 +1341,11 @@ val hash_iter_peek(struct hash_iter *hi)
if (!h)
return nil;
- do {
+ while (index <= mask) {
val cell = hi->table->v.vec[index++];
if (cell)
return cell;
- } while (index <= mask);
+ }
return nil;
}