提交 ffac10c9 编写于 作者: E Eric Blake

qemu: Avoid memleak on failure to format blockjobs

virXMLFormatElement() frees attrBuf on success, but not necessarily
on failure. Most other callers of this function take the time to
reset attrBuf afterwords, but qemuDomainObjPrivateXMLFormatBlockjobs()
was relying on it succeeding, and could thus result in a memory leak.
Signed-off-by: NEric Blake <eblake@redhat.com>
ACKed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 c0790e3a
......@@ -2232,11 +2232,14 @@ qemuDomainObjPrivateXMLFormatBlockjobs(virBufferPtr buf,
{
virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
bool bj = qemuDomainHasBlockjob(vm, false);
int ret;
virBufferAsprintf(&attrBuf, " active='%s'",
virTristateBoolTypeToString(virTristateBoolFromBool(bj)));
return virXMLFormatElement(buf, "blockjobs", &attrBuf, NULL);
ret = virXMLFormatElement(buf, "blockjobs", &attrBuf, NULL);
virBufferFreeAndReset(&attrBuf);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册