diff --git a/src/libvirt.c b/src/libvirt.c index 87a4d46fc4c06e82fa46819b9a7cfe62699a6eaa..27e469729e6dabc27606f7862064d1eee859bfab 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -4144,11 +4144,12 @@ virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) virResetLastError(); + if (info) + memset(info, 0, sizeof(*info)); + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(info, error); - memset(info, 0, sizeof(virDomainInfo)); - conn = domain->conn; if (conn->driver->domainGetInfo) { @@ -8449,12 +8450,13 @@ virDomainGetBlockInfo(virDomainPtr domain, const char *disk, virResetLastError(); + if (info) + memset(info, 0, sizeof(*info)); + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(disk, error); virCheckNonNullArgGoto(info, error); - memset(info, 0, sizeof(virDomainBlockInfo)); - conn = domain->conn; if (conn->driver->domainGetBlockInfo) { @@ -13082,11 +13084,12 @@ virStoragePoolGetInfo(virStoragePoolPtr pool, virResetLastError(); + if (info) + memset(info, 0, sizeof(*info)); + virCheckStoragePoolReturn(pool, -1); virCheckNonNullArgGoto(info, error); - memset(info, 0, sizeof(virStoragePoolInfo)); - conn = pool->conn; if (conn->storageDriver->storagePoolGetInfo) { @@ -13951,11 +13954,12 @@ virStorageVolGetInfo(virStorageVolPtr vol, virResetLastError(); + if (info) + memset(info, 0, sizeof(*info)); + virCheckStorageVolReturn(vol, -1); virCheckNonNullArgGoto(info, error); - memset(info, 0, sizeof(virStorageVolInfo)); - conn = vol->conn; if (conn->storageDriver->storageVolGetInfo){ @@ -17240,11 +17244,12 @@ virDomainGetJobInfo(virDomainPtr domain, virDomainJobInfoPtr info) virResetLastError(); + if (info) + memset(info, 0, sizeof(*info)); + virCheckDomainReturn(domain, -1); virCheckNonNullArgGoto(info, error); - memset(info, 0, sizeof(virDomainJobInfo)); - conn = domain->conn; if (conn->driver->domainGetJobInfo) { @@ -19379,14 +19384,15 @@ virDomainGetBlockJobInfo(virDomainPtr dom, const char *disk, virResetLastError(); + if (info) + memset(info, 0, sizeof(*info)); + virCheckDomainReturn(dom, -1); conn = dom->conn; virCheckNonNullArgGoto(disk, error); virCheckNonNullArgGoto(info, error); - memset(info, 0, sizeof(*info)); - if (conn->driver->domainGetBlockJobInfo) { int ret; ret = conn->driver->domainGetBlockJobInfo(dom, disk, info, flags);