From: Frantisek Sumsal Date: Sun, 21 May 2023 19:00:26 +0000 (+0200) Subject: shared: correctly propagate possible allocation errors X-Git-Tag: v254-rc1~419^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3575c371697a07995c3e65ae03aed55262ab00ed;p=thirdparty%2Fsystemd.git shared: correctly propagate possible allocation errors instead of just asserting in case the memstream couldn't be resized. Found by Nallocufuzz. --- diff --git a/src/shared/json.c b/src/shared/json.c index 8962173b3ae..904b26f9867 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);