diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-05-25 15:54:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-25 22:54:57 +0800 |
commit | 27bdcbbd831b9dc742058916b2a7b2d523afac68 (patch) | |
tree | 154402e2f40f3f5ce41657f2fc91d970244fb0d4 /test/ufuzz/index.js | |
parent | 2c4d7d66efca56d89bc4acbfec63ac034570bcaa (diff) | |
download | tracifyjs-27bdcbbd831b9dc742058916b2a7b2d523afac68.tar.gz tracifyjs-27bdcbbd831b9dc742058916b2a7b2d523afac68.zip |
fix corner cases in infinite recursion detection (#3924)
Diffstat (limited to 'test/ufuzz/index.js')
-rw-r--r-- | test/ufuzz/index.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js index ed687def..df946c99 100644 --- a/test/ufuzz/index.js +++ b/test/ufuzz/index.js @@ -1177,19 +1177,19 @@ function skip_infinite_recursion(orig, toplevel) { var code = orig; var tries = []; var offset = 0; - var re = /(?:(?:^|[\s{};])try|}\s*catch\s*\(([^)]+)\)|}\s*finally)\s*(?={)/g; + var re = /(?:(?:^|[\s{});])try|}\s*catch\s*\(([^)]+)\)|}\s*finally)\s*(?={)/g; var match; while (match = re.exec(code)) { if (/}\s*finally\s*$/.test(match[0])) { tries.shift(); continue; } - if (tries.length && tries[0].catch) tries.shift(); var index = match.index + match[0].length + 1; - if (/(?:^|[\s{};])try\s*$/.test(match[0])) { + if (/(?:^|[\s{});])try\s*$/.test(match[0])) { tries.unshift({ try: index - offset }); continue; } + while (tries.length && tries[0].catch) tries.shift(); tries[0].catch = index; var insert = "throw " + match[1] + ".ufuzz_skip || (" + match[1] + ".ufuzz_skip = " + tries[0].try + "), " + match[1] + ";"; var new_code = code.slice(0, index) + insert + code.slice(index); |