]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsystemdtest: do not leak socket path
authorJán Tomko <jtomko@redhat.com>
Fri, 21 Feb 2020 23:57:33 +0000 (00:57 +0100)
committerJán Tomko <jtomko@redhat.com>
Mon, 9 Mar 2020 14:46:43 +0000 (15:46 +0100)
Use an autofree'd helper variable to store the socket path
and free it after the function finishes.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 5b8569dd6e284b9159c701e8bffafb196983fc4a
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/virsystemdtest.c

index b7dfd64d06151a414dd0f6ef4433c1427f4fc6c1..1e362981890e49ff37e69e16b43289335f9b8530 100644 (file)
@@ -555,12 +555,15 @@ testActivation(bool useNames)
     size_t nfds = 0;
     g_autoptr(virSystemdActivation) act = NULL;
     g_auto(virBuffer) names = VIR_BUFFER_INITIALIZER;
+    g_autofree char *demo_socket_path = NULL;
 
     virBufferAddLit(&names, "demo-unix.socket");
 
     if (testActivationCreateFDs(&sockUNIX, &sockIP, &nsockIP) < 0)
         return -1;
 
+    demo_socket_path = virNetSocketGetPath(sockUNIX);
+
     for (i = 0; i < nsockIP; i++)
         virBufferAddLit(&names, ":demo-ip.socket");
 
@@ -577,7 +580,7 @@ testActivation(bool useNames)
 
     map[0].name = "demo-unix.socket";
     map[0].family = AF_UNIX;
-    map[0].path = virNetSocketGetPath(sockUNIX);
+    map[0].path = demo_socket_path;
 
     map[1].name = "demo-ip.socket";
     map[1].family = AF_INET;