[libvirt PATCH] qemu: agent: fix array access

Ján Tomko posted 1 patch 4 years, 1 month ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/107cbef93c2d431dad3da84d065dcbd7a8462445.1602766847.git.jtomko@redhat.com
src/qemu/qemu_agent.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[libvirt PATCH] qemu: agent: fix array access
Posted by Ján Tomko 4 years, 1 month ago
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@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

Re: [libvirt PATCH] qemu: agent: fix array access
Posted by Michal Privoznik 4 years, 1 month ago
On 10/15/20 3:00 PM, Ján Tomko wrote:
> 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@redhat.com>
> Fixes: 6ddb1f803ea38d8d709b984fa9539e34318a9dc0
> ---
>   src/qemu/qemu_agent.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal