From: Peter Krempa Date: Thu, 19 Dec 2013 11:24:26 +0000 (+0100) Subject: storage: Use VIR_DELETE_ELEMENT instead of open coding X-Git-Tag: CVE-2013-6458-1~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cad3cf9a951d26da9d2ee0f5b52fb1a2dbb74af1;p=thirdparty%2Flibvirt.git storage: Use VIR_DELETE_ELEMENT instead of open coding Replace the open coded array element deletion by our new helper. --- diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index baba9c9282..aaa0f0286d 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1565,17 +1565,8 @@ storageVolDelete(virStorageVolPtr obj, VIR_INFO("Deleting volume '%s' from storage pool '%s'", vol->name, pool->def->name); virStorageVolDefFree(vol); - vol = NULL; - - if (i < (pool->volumes.count - 1)) - memmove(pool->volumes.objs + i, pool->volumes.objs + i + 1, - sizeof(*(pool->volumes.objs)) * (pool->volumes.count - (i + 1))); - - if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count - 1) < 0) { - ; /* Failure to reduce memory allocation isn't fatal */ - } - pool->volumes.count--; + VIR_DELETE_ELEMENT(pool->volumes.objs, pool->volumes.count, i); break; } }