From: Michal Privoznik Date: Thu, 25 Feb 2021 10:58:38 +0000 (+0100) Subject: virtpm: Fix @path handling in virTPMEmulatorInit() X-Git-Tag: v7.2.0-rc1~301 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=144cb28e6b1a1c26a1cd00864432c161785e0307;p=thirdparty%2Flibvirt.git virtpm: Fix @path handling in virTPMEmulatorInit() This function finds "swtmp", "swtpm_setup" and "swtpm_ioctl" binaries in $PATH and stores resolved paths in global variables so that they can be obtainer later. Anyway, the resolved path is marked as g_autofree and to avoid its freeing later on in the function the variable is set to NULL manually. Well, we have g_steal_pointer() for that. Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- diff --git a/src/util/virtpm.c b/src/util/virtpm.c index b41eb00619..128ca0c579 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -323,16 +323,14 @@ virTPMEmulatorInit(void) _("Could not stat %s"), path); goto cleanup; } - *prgs[i].path = path; + *prgs[i].path = g_steal_pointer(&path); if (prgs[i].caps) { *prgs[i].caps = virTPMGetCaps(prgs[i].typeFromStringFn, - path, prgs[i].parm); - path = NULL; + *prgs[i].path, prgs[i].parm); if (!*prgs[i].caps) goto cleanup; } - path = NULL; } }