[LTP] [PATCH 2/5] libs/ujson: Fix "Garbage after JSON string!" in strict mode
Cyril Hrubis
chrubis@suse.cz
Tue Dec 3 16:15:27 CET 2024
In strict mode warnings are converted into errors and filled into the
error buffer rather than being printed right away. That means that we
have to print error buffer after we issue a warning so that it's printed
in the strict mode (UJSON_READER_STRICT) as well.
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
libs/ujson/ujson_reader.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libs/ujson/ujson_reader.c b/libs/ujson/ujson_reader.c
index d508f00d3..9f86f25b7 100644
--- a/libs/ujson/ujson_reader.c
+++ b/libs/ujson/ujson_reader.c
@@ -1049,8 +1049,12 @@ void ujson_reader_finish(ujson_reader *self)
{
if (ujson_reader_err(self))
ujson_err_print(self);
- else if (!ujson_reader_consumed(self))
+ else if (!ujson_reader_consumed(self)) {
ujson_warn(self, "Garbage after JSON string!");
+
+ if (ujson_reader_err(self))
+ ujson_err_print(self);
+ }
}
void ujson_reader_free(ujson_reader *buf)
--
2.45.2
More information about the ltp
mailing list