mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-08 14:03:14 +00:00
Merge pull request #5934 from BradLewis/fix/oob-parser
Fix out of bounds access when parsing end_pos
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user