mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
qemuBuildHostNetStr: Don't leak buffer
If there was an error when constructing the buffer, NULL is returned. The buffer is never freed though. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
ff5c5a9bbb
commit
891b3c119e
@ -3805,13 +3805,13 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
|
|||||||
virDomainNetType netType = virDomainNetGetActualType(net);
|
virDomainNetType netType = virDomainNetGetActualType(net);
|
||||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||||
size_t i;
|
size_t i;
|
||||||
|
char *ret = NULL;
|
||||||
|
|
||||||
if (net->script && netType != VIR_DOMAIN_NET_TYPE_ETHERNET) {
|
if (net->script && netType != VIR_DOMAIN_NET_TYPE_ETHERNET) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("scripts are not supported on interfaces of type %s"),
|
_("scripts are not supported on interfaces of type %s"),
|
||||||
virDomainNetTypeToString(netType));
|
virDomainNetTypeToString(netType));
|
||||||
virObjectUnref(cfg);
|
goto cleanup;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (netType) {
|
switch (netType) {
|
||||||
@ -3919,13 +3919,16 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
|
|||||||
virBufferAsprintf(&buf, "sndbuf=%lu,", net->tune.sndbuf);
|
virBufferAsprintf(&buf, "sndbuf=%lu,", net->tune.sndbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
virObjectUnref(cfg);
|
|
||||||
|
|
||||||
virBufferTrim(&buf, ",", -1);
|
virBufferTrim(&buf, ",", -1);
|
||||||
if (virBufferCheckError(&buf) < 0)
|
if (virBufferCheckError(&buf) < 0)
|
||||||
return NULL;
|
goto cleanup;
|
||||||
|
|
||||||
return virBufferContentAndReset(&buf);
|
ret = virBufferContentAndReset(&buf);
|
||||||
|
cleanup:
|
||||||
|
virBufferFreeAndReset(&buf);
|
||||||
|
virObjectUnref(cfg);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user