[LTP] [PATCH v2 05/15] ujson: reader: Return UTF-8 length when !str
Andrea Cervesato
andrea.cervesato@suse.de
Tue Oct 13 14:02:01 CEST 2026
From: Andrea Cervesato <andrea.cervesato@suse.com>
When parse_ucode_esc() is called without an output buffer to calculate
string length, it returned the unicode code point instead of the UTF-8
byte length. This vastly overestimated the required buffer size. Return
the UTF-8 byte length instead.
Fixes: c50a0e0751c8 ("libs: Vendor ujson library")
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
libs/ujson/ujson_reader.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libs/ujson/ujson_reader.c b/libs/ujson/ujson_reader.c
index 3cd7fcce5..6dde06e01 100644
--- a/libs/ujson/ujson_reader.c
+++ b/libs/ujson/ujson_reader.c
@@ -135,7 +135,7 @@ static unsigned int parse_ucode_esc(ujson_reader *buf, char *str,
return 0;
if (!str)
- return ucode;
+ return ujson_utf8_bytes(ucode);
if (ujson_utf8_bytes(ucode) + 1 >= len - off) {
ujson_err(buf, "String buffer too short!");
--
2.51.0
More information about the ltp
mailing list