diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-10-15 06:14:15 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-10-15 07:24:58 +0200 |
commit | d1ac7d76b42cfceabb9a4c30b11283ec4b585c4e (patch) | |
tree | 1952b980b75991667d8ef3588f47f845349a911b /src/machine | |
parent | machine: lookup_machine_by_name_or_pid() may return 1 on error and it is alre... (diff) | |
download | systemd-d1ac7d76b42cfceabb9a4c30b11283ec4b585c4e.tar.xz systemd-d1ac7d76b42cfceabb9a4c30b11283ec4b585c4e.zip |
machine: fix memleak in vl_method_list_images()
Fixes an issue in fb0ea6a6a36b5fa97e6c57d608bb9f7acb63c8b2.
Diffstat (limited to 'src/machine')
-rw-r--r-- | src/machine/machined-varlink.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/machine/machined-varlink.c b/src/machine/machined-varlink.c index bd5dbf7e67..4b167c8fac 100644 --- a/src/machine/machined-varlink.c +++ b/src/machine/machined-varlink.c @@ -583,16 +583,18 @@ static int vl_method_list_images(sd_varlink *link, sd_json_variant *parameters, return r; if (p.image_name) { + _cleanup_(image_unrefp) Image *found = NULL; + if (!image_name_is_valid(p.image_name)) return sd_varlink_error_invalid_parameter_name(link, "name"); - r = image_find(IMAGE_MACHINE, p.image_name, /* root = */ NULL, &image); + r = image_find(IMAGE_MACHINE, p.image_name, /* root = */ NULL, &found); if (r == -ENOENT) return sd_varlink_error(link, "io.systemd.MachineImage.NoSuchImage", NULL); if (r < 0) return log_debug_errno(r, "Failed to find image: %m"); - return list_image_one_and_maybe_read_metadata(link, image, /* more = */ false, p.acquire_metadata); + return list_image_one_and_maybe_read_metadata(link, found, /* more = */ false, p.acquire_metadata); } if (!FLAGS_SET(flags, SD_VARLINK_METHOD_MORE)) |