1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-17 20:58:08 +02:00

Prevent panic from hax lexer (#812)

Prevents `runtime error: slice bounds out of range` when list is empty.
This commit is contained in:
Alan Hamlett 2023-08-15 23:50:03 +02:00 committed by GitHub
parent 2aad7403e6
commit 68d976f00b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -630,7 +630,9 @@ func haxePreProcMutator(state *LexerState) error {
state.Stack = stack[len(stack)-1]
}
case "end":
stack = stack[:len(stack)-1]
if len(stack) > 0 {
stack = stack[:len(stack)-1]
}
}
if proc == "if" || proc == "elseif" {