]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
network: Remove conditional settings to resolve resource leak
authorJohn Ferlan <jferlan@redhat.com>
Wed, 30 Jan 2013 12:21:28 +0000 (07:21 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 5 Feb 2013 21:51:07 +0000 (16:51 -0500)
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

index dadcc6c2ac1e9a40e30e6ac58bfadcb833b9494d..c834f8362654fce79d5708fa12c3314386d02efb 100644 (file)
@@ -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;
 }