mirror of
https://github.com/odin-lang/Odin.git
synced 2026-05-27 06:08:13 +00:00
Merge pull request #6669 from BradLewis/fix/json-handle-invalid-utf8
Handle invalid utf8 when parsing json
This commit is contained in:
@@ -474,7 +474,10 @@ unquote_string :: proc(token: Token, spec: Specification, allocator := context.a
|
||||
i += width
|
||||
|
||||
buf, buf_width := utf8.encode_rune(r)
|
||||
assert(buf_width <= width)
|
||||
// If we have an invalid utf8 character, width can be smaller than the width of RUNE_ERROR
|
||||
if r != utf8.RUNE_ERROR {
|
||||
assert(buf_width <= width)
|
||||
}
|
||||
copy(b[w:], buf[:buf_width])
|
||||
w += buf_width
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user