diff options
author | Jo-Philipp Wich <jo@mein.io> | 2024-10-17 16:32:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-17 16:32:02 +0200 |
commit | 402280dca0fe43c14b4cedbdf5263eeb2f33d745 (patch) | |
tree | 206a057ffa23d2ac9f5e0f1a1f0978c79288bdd3 /tests | |
parent | 07afe9636894e259d148b429bb30a85fd51658e1 (diff) | |
parent | 736d4508420222321468feedd60e7cb5063b574d (diff) |
Merge pull request #239 from jow-/safe-insert-during-obj-iteration
types: fix potential use after free on adding keys during iteration
Diffstat (limited to 'tests')
-rw-r--r-- | tests/custom/99_bugs/48_use_after_free_on_iteration_insert | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/custom/99_bugs/48_use_after_free_on_iteration_insert b/tests/custom/99_bugs/48_use_after_free_on_iteration_insert new file mode 100644 index 0000000..558f83a --- /dev/null +++ b/tests/custom/99_bugs/48_use_after_free_on_iteration_insert @@ -0,0 +1,40 @@ +Ensure that adding keys to an object currently being iterated will not +clobber active iterators pointing into that object due to a reallocation +of the underlying hash table array. + +-- Testcase -- +{% + let obj = { '0': 0, '1': 1 }; + let i = 2; + + for (let k, v in obj) { + while (i < 16) { + obj[i] = i; + i++; + } + } + + printf("%.J\n", obj); +%} +-- End -- + +-- Expect stdout -- +{ + "0": 0, + "1": 1, + "2": 2, + "3": 3, + "4": 4, + "5": 5, + "6": 6, + "7": 7, + "8": 8, + "9": 9, + "10": 10, + "11": 11, + "12": 12, + "13": 13, + "14": 14, + "15": 15 +} +-- End -- |