]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virfile: Resolve Coverity RESOURCE_LEAK
authorJohn Ferlan <jferlan@redhat.com>
Thu, 11 Sep 2014 21:05:34 +0000 (17:05 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Fri, 12 Sep 2014 10:12:50 +0000 (06:12 -0400)
With the virGetGroupList() change in place - Coverity further complains
that if we fail to virFork(), the groups will be leaked - which aha seems
to be the case. Adjust the logic to save off the -errno, free the groups,
and then return the value we saved

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/util/virfile.c

index 7c506c9a78374cd047f168e4190ca1f85b86d2fa..b3b8be2bf893cbbb1d85dbd6ddb6e67f9b04a405 100644 (file)
@@ -2000,8 +2000,11 @@ virFileOpenForked(const char *path, int openflags, mode_t mode,
     }
 
     pid = virFork();
-    if (pid < 0)
-        return -errno;
+    if (pid < 0) {
+        ret = -errno;
+        VIR_FREE(groups);
+        return ret;
+    }
 
     if (pid == 0) {