From 978756ad37ecf36201fe6f94a6773d2406b9b276 Mon Sep 17 00:00:00 2001 From: Fabrice Bellard Date: Thu, 20 Mar 2025 11:47:07 +0100 Subject: [PATCH] protect against printf errors (#319) --- cutils.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cutils.c b/cutils.c index c0aacef..c038cf4 100644 --- a/cutils.c +++ b/cutils.c @@ -176,6 +176,8 @@ int __attribute__((format(printf, 2, 3))) dbuf_printf(DynBuf *s, va_start(ap, fmt); len = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); + if (len < 0) + return -1; if (len < sizeof(buf)) { /* fast case */ return dbuf_put(s, (uint8_t *)buf, len);