From 3fa23653eef29ba23a8925b9c741daad68e0c23e Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Wed, 30 Jan 2013 07:21:28 -0500 Subject: [PATCH] network: Remove conditional settings to resolve resource leak The conditional setting of cmdout in networkBuildDhcpDaemonCommandLine() caused Coverity to complain that 'cmd' could be leaked if !cmdout. Since the function is local and only called with cmdout being passed those checks have been removed. --- src/network/bridge_driver.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index dadcc6c2ac..c834f83626 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -994,8 +994,9 @@ cleanup: } /* build the dnsmasq command line */ -static int -networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network, virCommandPtr *cmdout, +static int ATTRIBUTE_NONNULL(2) +networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network, + virCommandPtr *cmdout, char *pidfile, dnsmasqContext *dctx, dnsmasqCapsPtr caps) { @@ -1027,13 +1028,9 @@ networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network, virCommandPtr *cmdou cmd = virCommandNew(dnsmasqCapsGetBinaryPath(caps)); virCommandAddArgFormat(cmd, "--conf-file=%s", configfile); - - if (cmdout) - *cmdout = cmd; + *cmdout = cmd; ret = 0; cleanup: - if (ret < 0) - virCommandFree(cmd); return ret; } -- GitLab