提交 a8412f86 编写于 作者: D Daniel P. Berrange

Fix leak of comment string if virConfAddEntry fails on OOM

The code parsing comments in config files called virConfAddEntry
but did not check for failure. This caused the comment string to
leak on OOM.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 1f66001c
......@@ -589,7 +589,10 @@ virConfParseComment(virConfParserCtxtPtr ctxt)
while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
if (VIR_STRNDUP(comm, base, ctxt->cur - base) < 0)
return -1;
virConfAddEntry(ctxt->conf, NULL, NULL, comm);
if (virConfAddEntry(ctxt->conf, NULL, NULL, comm) == NULL) {
VIR_FREE(comm);
return -1;
}
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册