mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-27 18:03:50 +03: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 baafe668fa56767c031468ccd5df3e62eaa11370.
This commit is contained in:
parent
835dc0133f
commit
23c2763b4f
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user