提交 4644f0b2 编写于 作者: E Eric Blake

storage: avoid null deref and leak on failure

Detected by clang.  NULL deref added in commit 343a27af (Mar 11),
but leak of voldef present since commit 2cd9b2d8 (Apr 09).

* src/storage/storage_driver.c (storageVolumeCreateXML): Don't
leak voldef or dereference null volobj.
上级 6eb3a1f4
/*
* storage_driver.c: core driver for storage APIs
*
* Copyright (C) 2006-2010 Red Hat, Inc.
* Copyright (C) 2006-2011 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
......@@ -1319,8 +1319,12 @@ storageVolumeCreateXML(virStoragePoolPtr obj,
pool->volumes.objs[pool->volumes.count++] = voldef;
volobj = virGetStorageVol(obj->conn, pool->def->name, voldef->name,
voldef->key);
if (!volobj) {
pool->volumes.count--;
goto cleanup;
}
if (volobj && backend->buildVol) {
if (backend->buildVol) {
int buildret;
virStorageVolDefPtr buildvoldef = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册