Merge pull request #6669 from BradLewis/fix/json-handle-invalid-utf8

Handle invalid utf8 when parsing json
This commit is contained in:
gingerBill
2026-05-12 14:40:49 +01:00
committed by GitHub

View File

@@ -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
}