Re: [libvirt PATCH 1/2] conf: fix g_new0 allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/12/20 2:13 PM, Pavel Hrdina wrote:
Fixes commit <a5d88ffe0ad9b5d5314ab0058c5b363f9f79b8ee> which changed
allocation from VIR_ALLOC_N to g_new0 but missed some +1 on number of
allocated elements.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
  src/conf/virinterfaceobj.c  | 2 +-
  src/conf/virnetworkobj.c    | 4 ++--
  src/conf/virnodedeviceobj.c | 2 +-
  3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c
index 5a5fd65e14..e08b4b9b0f 100644
--- a/src/conf/virinterfaceobj.c
+++ b/src/conf/virinterfaceobj.c
@@ -320,7 +320,7 @@ virInterfaceObjListExport(virConnectPtr conn,
virObjectRWLockRead(ifaceobjs);
      if (ifaces)
-        data.ifaces = g_new0(virInterfacePtr, virHashSize(ifaceobjs->objsName));
+        data.ifaces = g_new0(virInterfacePtr, virHashSize(ifaceobjs->objsName) + 1);
virHashForEach(ifaceobjs->objsName, virInterfaceObjListExportCallback, &data); diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index 1fcfa9cdc2..a2835ebf8e 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -1407,7 +1407,7 @@ virNetworkObjListExport(virConnectPtr conn,
virObjectRWLockRead(netobjs);
      if (nets)
-        data.nets = g_new0(virNetworkPtr, virHashSize(netobjs->objs));
+        data.nets = g_new0(virNetworkPtr, virHashSize(netobjs->objs) + 1);
virHashForEach(netobjs->objs, virNetworkObjListExportCallback, &data); @@ -1801,7 +1801,7 @@ virNetworkObjPortListExport(virNetworkPtr net,
      if (ports) {
          *ports = NULL;
- data.ports = g_new0(virNetworkPortPtr, virHashSize(obj->ports));
+        data.ports = g_new0(virNetworkPortPtr, virHashSize(obj->ports) + 1);
      }
virHashForEach(obj->ports, virNetworkObjPortListExportCallback, &data);
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index 28905c67b6..9af80b8036 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -931,7 +931,7 @@ virNodeDeviceObjListExport(virConnectPtr conn,
virObjectRWLockRead(devs);
      if (devices)
-        data.devices = g_new0(virNodeDevicePtr, virHashSize(devs->objs));
+        data.devices = g_new0(virNodeDevicePtr, virHashSize(devs->objs) + 1);
virHashForEach(devs->objs, virNodeDeviceObjListExportCallback, &data);
      virObjectRWUnlock(devs);


Reviewed-by: Laine Stump <laine@xxxxxxxxxx>




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux