From: John Ferlan Date: Fri, 22 Aug 2014 15:01:04 +0000 (-0400) Subject: virnetsocket: Resolve Coverity RESOURCE_LEAK X-Git-Tag: v1.2.8-rc1~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc1bbbbebae3c13669a3446db0b539b7038098ff;p=thirdparty%2Flibvirt.git virnetsocket: Resolve Coverity RESOURCE_LEAK 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 --- diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index f913365fd5..79258efe17 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -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;