[libvirt PATCH 2/2] conf: virsecretobj: fix g_new0 allocation

Pavel Hrdina phrdina at redhat.com
Mon Oct 12 18:13:29 UTC 2020


Fixes commit <d5b05614dfbc9bd60ea1a31a9cc32aaf3c771ddc> which changed
allocation from VIR_ALLOC_N to g_new0 but missed one +1 on number of
allocated elements.

Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 src/conf/virsecretobj.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
index c98d52f1e4..d74deb9316 100644
--- a/src/conf/virsecretobj.c
+++ b/src/conf/virsecretobj.c
@@ -588,7 +588,7 @@ virSecretObjListExport(virConnectPtr conn,
 
     virObjectRWLockRead(secretobjs);
     if (secrets)
-        data.secrets = g_new0(virSecretPtr, virHashSize(secretobjs->objs));
+        data.secrets = g_new0(virSecretPtr, virHashSize(secretobjs->objs) + 1);
 
     virHashForEach(secretobjs->objs, virSecretObjListExportCallback, &data);
     virObjectRWUnlock(secretobjs);
-- 
2.26.2




More information about the libvir-list mailing list