[LTP] [PATCH 08/15] ujson: writer: Check return value in ESC_FLUSH

Andrea Cervesato andrea.cervesato@suse.de
Mon Oct 5 15:25:36 CEST 2026


From: Andrea Cervesato <andrea.cervesato@suse.com>

ESC_FLUSH ignores the return values of out() and out_str().
If an output error occurs while flushing escaped characters, the error
is ignored and writing continues. Check the return values and return
immediately on failure.

Fixes: c50a0e0751c8 ("libs: Vendor ujson library")
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 libs/ujson/ujson_writer.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libs/ujson/ujson_writer.c b/libs/ujson/ujson_writer.c
index c203ee079..15faca9be 100644
--- a/libs/ujson/ujson_writer.c
+++ b/libs/ujson/ujson_writer.c
@@ -98,10 +98,12 @@ static inline int out_ch(ujson_writer *self, char ch)
 }
 
 #define ESC_FLUSH(esc_char) do {\
-	out(self, val, i); \
+	if (out(self, val, i)) \
+		return 1; \
 	val += i + 1; \
 	i = 0; \
-	out_str(self, esc_char); \
+	if (out_str(self, esc_char)) \
+		return 1; \
 } while (0)
 
 static inline int out_esc_str(ujson_writer *self, const char *val)

-- 
2.51.0



More information about the ltp mailing list