LibRegex: Fix crash when parse result exceeds max cache size

Before, If the cache was empty we would try and evict non-existant
entries and crash. So the fix is to make sure that we don't saturate
the cache with a single parse result.
This commit is contained in:
Jess 2025-04-05 01:38:32 +13:00 committed by Ali Mohammad Pur
commit 83e46b3728
Notes: github-actions[bot] 2025-04-04 14:11:28 +00:00
2 changed files with 21 additions and 6 deletions

View file

@ -77,3 +77,7 @@ test("v flag should enable unicode mode", () => {
const re = new RegExp("a\\u{10FFFF}", "v");
expect(re.test("a\u{10FFFF}")).toBe(true);
});
test("parsing a large bytestring shouldn't crash", () => {
RegExp(new Uint8Array(0x40000));
});