1
0
mirror of https://github.com/janet-lang/janet synced 2025-09-07 21:36:08 +00:00

Address issue #1539 - infinite loop in peg split

Other looping rules ensure forward progress by terminating if an
iteration is at the same location as the previous iteration. Do the same
for split.
This commit is contained in:
Calvin Rose
2025-01-01 11:26:43 -06:00
parent f252933f62
commit 60d9f97750
2 changed files with 31 additions and 17 deletions

View File

@@ -772,5 +772,16 @@
"5:apple6:banana6:cherry"
@["apple" "banana" "cherry"])
# Issue #1539 - make sure split with "" doesn't infinite loop/oom
(test "issue 1539"
~(split "" (capture (to -1)))
"hello there friends"
nil)
(test "issue 1539 pt. 2"
~(split "," (capture 0))
"abc123,,,,"
@["" "" "" "" ""])
(end-suite)