Skip to content

Commit

Permalink
Prevent slicing beyond bounds.
Browse files Browse the repository at this point in the history
Apply same fix as in #325.

Fixes #333 ArraySliceError.
  • Loading branch information
veelo committed Sep 1, 2023
1 parent 31e02e2 commit bdd26d3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pegged/peg.d
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,7 @@ template longest_match(rules...) if (rules.length > 0)
foreach(i; 0..rules.length)
if (failedLength[i] == maxFailedLength && results[i].matches.length > 0)
errString ~= results[i].matches[$-1] ~ names[i][] ~ " or ";
orErrorString = errString[0..$-4];
orErrorString = errString[0..$ >= 4 ? $-4 : $];
longestFail.matches = longestFail.matches.length == 0 ? [orErrorString] :
longestFail.matches[0..$-1] // discarding longestFail error message
Expand Down

0 comments on commit bdd26d3

Please sign in to comment.