From 4267f1eb566e2d8279c82268ef79c2704bf0d850 Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Sat, 15 Nov 2025 18:41:30 -0500 Subject: [PATCH] Fix out of bounds access when parsing end_pos --- core/odin/parser/parser.odin | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index ce088fc64..f4beddcbb 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -99,19 +99,15 @@ end_pos :: proc(tok: tokenizer.Token) -> tokenizer.Pos { pos := tok.pos pos.offset += len(tok.text) - if tok.kind == .Comment || tok.kind == .String { - if tok.text[:2] == "/*" || tok.text[:1] == "`" { - for i := 0; i < len(tok.text); i += 1 { - c := tok.text[i] - if c == '\n' { - pos.line += 1 - pos.column = 1 - } else { - pos.column += 1 - } + if (tok.kind == .Comment && tok.text[:2] == "/*") || (tok.kind == .String && tok.text[:1] == "`") { + for i := 0; i < len(tok.text); i += 1 { + c := tok.text[i] + if c == '\n' { + pos.line += 1 + pos.column = 1 + } else { + pos.column += 1 } - } else { - pos.column += len(tok.text) } } else { pos.column += len(tok.text)