From 87d58b9fb77de00c7221049f3e4edcb6902b5536 Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Sun, 10 May 2026 16:17:39 +1000 Subject: [PATCH] Handle invalid utf8 when parsing json --- core/encoding/json/parser.odin | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/encoding/json/parser.odin b/core/encoding/json/parser.odin index cd6518955..58a47d308 100644 --- a/core/encoding/json/parser.odin +++ b/core/encoding/json/parser.odin @@ -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 }