1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

shared/json: fix memleak in sort

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-05-10 10:51:43 +02:00
parent 3b6ce05537
commit 99b1145aae
2 changed files with 3 additions and 2 deletions

View File

@ -4581,7 +4581,7 @@ static int json_cmp_strings(const void *x, const void *y) {
int json_variant_sort(JsonVariant **v) {
_cleanup_free_ JsonVariant **a = NULL;
JsonVariant *n = NULL;
_cleanup_(json_variant_unrefp) JsonVariant *n = NULL;
size_t m;
int r;
@ -4614,7 +4614,7 @@ int json_variant_sort(JsonVariant **v) {
if (!n->sorted) /* Check if this worked. This will fail if there are multiple identical keys used. */
return -ENOTUNIQ;
JSON_VARIANT_REPLACE(*v, n);
JSON_VARIANT_REPLACE(*v, TAKE_PTR(n));
return 1;
}

View File

@ -0,0 +1 @@
{"":2,"":6,"-":7}