shared: correctly propagate possible allocation errors

instead of just asserting in case the memstream couldn't be resized.

Found by Nallocufuzz.
This commit is contained in:
Frantisek Sumsal
2023-05-22 12:39:47 +02:00
parent 6554f56361
commit 3575c37169
+3 -1
View File
@@ -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);