Skip to content

Commit

Permalink
fix an infinite loop in map insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Nov 22, 2024
1 parent 0fce8a1 commit 156d82b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/algorithm/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ impl MapKeys {
let orig = key_index;
loop {
key_index = (key_index + 1) % capacity;
if key_index == orig {
break false;
}
let cell_key =
&key_data[key_index * key_row_len..(key_index + 1) * key_row_len];
if cell_key[0].is_any_tombstone() {
Expand Down
5 changes: 5 additions & 0 deletions tests/map.ua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ map ⟜(⇡⧻)
remove "zh"
insert "kmsq" 0
⍤⤙≍ ∩⧻°map
map {"a" "b" "c"} [1 2 3]
remove "b"
insert "d" 4
insert "e" 42
⍤⤙≍ map {"a" "c" "d" "e"} [1 3 4 42]

# Duplicate init keys
⍤⤙≍ map [0 1] [3 4] map [0 0 0 1] [1 2 3 4]

0 comments on commit 156d82b

Please sign in to comment.