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 <noreply@anthropic.com>
Signed-off-by: Paul Meyer <katexochen0@gmail.com>
This commit is contained in:
Paul Meyer
2026-06-17 10:23:47 +02:00
parent 6212baaf82
commit 9f28938a84
+2 -2
View File
@@ -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();
}