aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaytan <laytanlaats@hotmail.com>2025-11-16 14:24:07 +0100
committerGitHub <noreply@github.com>2025-11-16 14:24:07 +0100
commit614e98f230b3a970f1a3e99cafb3da79a70e330b (patch)
tree057edab0d50a7f5a76022f4814733f4c828398c8
parent93fa00c19187f934cda7988a19409dd0181e2505 (diff)
parent4267f1eb566e2d8279c82268ef79c2704bf0d850 (diff)
Merge pull request #5934 from BradLewis/fix/oob-parser
Fix out of bounds access when parsing end_pos
-rw-r--r--core/odin/parser/parser.odin20
1 files 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)