mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
network: bridge: Avoid memory leak from networkBuildDhcpDaemonCommandLine
If the leasehelper_path couldn't be found the code would leak the
freshly constructed command structure. Re-arrange code to avoid the
problem.
Found by coverity, broken by baafe668fa.
This commit is contained in:
@@ -1273,15 +1273,14 @@ networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cmd = virCommandNew(dnsmasqCapsGetBinaryPath(caps));
|
||||
virCommandAddArgFormat(cmd, "--conf-file=%s", configfile);
|
||||
|
||||
/* This helper is used to create custom leases file for libvirt */
|
||||
if (!(leaseshelper_path = virFileFindResource("libvirt_leaseshelper",
|
||||
"src",
|
||||
LIBEXECDIR)))
|
||||
goto cleanup;
|
||||
|
||||
cmd = virCommandNew(dnsmasqCapsGetBinaryPath(caps));
|
||||
virCommandAddArgFormat(cmd, "--conf-file=%s", configfile);
|
||||
virCommandAddArgFormat(cmd, "--dhcp-script=%s", leaseshelper_path);
|
||||
|
||||
*cmdout = cmd;
|
||||
|
||||
Reference in New Issue
Block a user