Skip to content

Commit 614e98f

Browse files
authored
Merge pull request #5934 from BradLewis/fix/oob-parser
Fix out of bounds access when parsing end_pos
2 parents 93fa00c + 4267f1e commit 614e98f

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

core/odin/parser/parser.odin

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,15 @@ end_pos :: proc(tok: tokenizer.Token) -> tokenizer.Pos {
9999
pos := tok.pos
100100
pos.offset += len(tok.text)
101101

102-
if tok.kind == .Comment || tok.kind == .String {
103-
if tok.text[:2] == "/*" || tok.text[:1] == "`" {
104-
for i := 0; i < len(tok.text); i += 1 {
105-
c := tok.text[i]
106-
if c == '\n' {
107-
pos.line += 1
108-
pos.column = 1
109-
} else {
110-
pos.column += 1
111-
}
102+
if (tok.kind == .Comment && tok.text[:2] == "/*") || (tok.kind == .String && tok.text[:1] == "`") {
103+
for i := 0; i < len(tok.text); i += 1 {
104+
c := tok.text[i]
105+
if c == '\n' {
106+
pos.line += 1
107+
pos.column = 1
108+
} else {
109+
pos.column += 1
112110
}
113-
} else {
114-
pos.column += len(tok.text)
115111
}
116112
} else {
117113
pos.column += len(tok.text)

0 commit comments

Comments
 (0)