]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virnetsocket: Resolve Coverity RESOURCE_LEAK
authorJohn Ferlan <jferlan@redhat.com>
Fri, 22 Aug 2014 15:01:04 +0000 (11:01 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Fri, 22 Aug 2014 17:02:48 +0000 (13:02 -0400)
Since '1b807f92d' - Coverity complains that in the error paths of
both virFork() and virProcessWait() that the 'passfd' will not be closed.
Added the VIR_FORCE_CLOSE(passfd) and initialized it to -1.

Also noted that variable 'buf' was never really used - so I removed it

src/rpc/virnetsocket.c

index f913365fd5501641d928f8d4810ec4a223bf826c..79258efe174189d84175c2678c9188569bc6d783 100644 (file)
@@ -544,8 +544,7 @@ int virNetSocketNewConnectUNIX(const char *path,
                                const char *binary,
                                virNetSocketPtr *retsock)
 {
-    char *buf = NULL;
-    int fd, passfd;
+    int fd, passfd = -1;
     virSocketAddr localAddr;
     virSocketAddr remoteAddr;
 
@@ -647,8 +646,8 @@ int virNetSocketNewConnectUNIX(const char *path,
     return 0;
 
  error:
-    VIR_FREE(buf);
     VIR_FORCE_CLOSE(fd);
+    VIR_FORCE_CLOSE(passfd);
     if (spawnDaemon)
         unlink(path);
     return -1;