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.
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;