From 9f28938a842f8e936d2a59b3039c4db9c0e8077f Mon Sep 17 00:00:00 2001 From: Paul Meyer Date: Sat, 13 Jun 2026 09:58:53 +0200 Subject: [PATCH] vmspawn: don't leak prior arg_directory in ephemeral branch The ephemeral-snapshot branch did a bare arg_directory = strdup(...), orphaning the -D/--directory allocation from parse_argv. Use free_and_strdup(), matching the idiom already used elsewhere in the file. Co-developed-by: Claude Opus 4.8 Signed-off-by: Paul Meyer --- src/vmspawn/vmspawn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vmspawn/vmspawn.c b/src/vmspawn/vmspawn.c index f7cbb9c72d..3b53283bd8 100644 --- a/src/vmspawn/vmspawn.c +++ b/src/vmspawn/vmspawn.c @@ -3172,8 +3172,8 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) { if (r < 0) return log_error_errno(r, "Failed to create ephemeral snapshot of '%s': %m", arg_directory); - arg_directory = strdup(snapshot_directory); - if (!arg_directory) + r = free_and_strdup(&arg_directory, snapshot_directory); + if (r < 0) return log_oom(); }