From 3575c371697a07995c3e65ae03aed55262ab00ed Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sun, 21 May 2023 21:00:26 +0200 Subject: [PATCH] shared: correctly propagate possible allocation errors instead of just asserting in case the memstream couldn't be resized. Found by Nallocufuzz. --- src/shared/json.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/shared/json.c b/src/shared/json.c index 8962173b3a..904b26f986 100644 --- a/src/shared/json.c +++ b/src/shared/json.c @@ -1788,7 +1788,9 @@ int json_variant_format(JsonVariant *v, JsonFormatFlags flags, char **ret) { if (!f) return -ENOMEM; - json_variant_dump(v, flags, f, NULL); + r = json_variant_dump(v, flags, f, NULL); + if (r < 0) + return r; /* Add terminating 0, so that the output buffer is a valid string. */ fputc('\0', f);