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:
parent
3b6ce05537
commit
99b1145aae
@ -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;
|
||||
}
|
||||
|
1
test/fuzz/fuzz-json/leak-sort
Normal file
1
test/fuzz/fuzz-json/leak-sort
Normal file
@ -0,0 +1 @@
|
||||
{"":2,"":6,"-":7}
|
Loading…
Reference in New Issue
Block a user