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

Fix crash on OOM parsing storage pool XML

The virStoragePoolDefParseSource method would set def->nhosts
before allocating def->hosts. If the allocation failed due to
OOM, the cleanup code would crash accessing out of bounds.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 0dff76c2
......@@ -594,11 +594,11 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
if ((n = virXPathNodeSet("./host", ctxt, &nodeset)) < 0)
goto cleanup;
source->nhost = n;
if (source->nhost) {
if (VIR_ALLOC_N(source->hosts, source->nhost) < 0)
if (n) {
if (VIR_ALLOC_N(source->hosts, n) < 0)
goto cleanup;
source->nhost = n;
for (i = 0; i < source->nhost; i++) {
name = virXMLPropString(nodeset[i], "name");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册