]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virtpm: Fix @path handling in virTPMEmulatorInit()
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 25 Feb 2021 10:58:38 +0000 (11:58 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 2 Mar 2021 08:49:23 +0000 (09:49 +0100)
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 <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virtpm.c

index b41eb00619cd956c8a0bd02e1a2e9940c738b0d5..128ca0c5794fe06615021406d2565b8869ec4174 100644 (file)
@@ -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;
         }
     }