tokener: clear pending surrogate on reset

Discard the previous document's high surrogate when resetting the tokener.
Otherwise the next Unicode escape can add a replacement character or
combine with a surrogate from the abandoned document.

Extend the existing incremental parse tests for incomplete input and a
fatal error, using independent next-document string expectations.

Fixes #984.
Reported-by: GeekQAQ (GitHub)
Assisted-by: OpenAI Codex (AI)
Reviewed-by: GPT-6 Luna (AI)
This commit is contained in:
qeqx committed 2026-10-10 20:06:11 +09:00
1 parent 9e99c1cfe7
commit 7662139501
3 files changed
+16 -1

No files matched your search

+1
View File
@@ -214,6 +214,7 @@ void json_tokener_reset(struct json_tokener *tok)
json_tokener_reset_level(tok, i);
tok->depth = 0;
tok->err = json_tokener_success;
tok->high_surrogate = 0;
}
struct json_object *json_tokener_parse(const char *str)