From cc1bbbbebae3c13669a3446db0b539b7038098ff Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Fri, 22 Aug 2014 11:01:04 -0400 Subject: [PATCH] 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 --- src/rpc/virnetsocket.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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; -- 2.47.2