[libvirt PATCH] qemu: agent: fix array access

Ján Tomko jtomko at redhat.com
Thu Oct 15 13:00:49 UTC 2020


My code movement changed the type of ifaces_ret from
virDomainInterfacePtr * to virDomainInterfacePtr **,
but failed to adjust the condition or dereference the
array correctly.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
Fixes: 6ddb1f803ea38d8d709b984fa9539e34318a9dc0
---
 src/qemu/qemu_agent.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index c9c4b034d3..4c61c5cdc6 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -2209,6 +2209,7 @@ qemuAgentGetAllInterfaceAddresses(virDomainInterfacePtr **ifaces_ret,
     size_t ifaces_count = 0;
     size_t i;
 
+    *ifaces_ret = NULL;
     /* Hash table to handle the interface alias */
     ifaces_store = virHashNew(NULL);
 
@@ -2223,9 +2224,9 @@ qemuAgentGetAllInterfaceAddresses(virDomainInterfacePtr **ifaces_ret,
     return ifaces_count;
 
  error:
-    if (ifaces_ret) {
+    if (*ifaces_ret) {
         for (i = 0; i < ifaces_count; i++)
-            virDomainInterfaceFree(*ifaces_ret[i]);
+            virDomainInterfaceFree((*ifaces_ret)[i]);
     }
     VIR_FREE(*ifaces_ret);
     return -1;
-- 
2.26.2




More information about the libvir-list mailing list