[PATCH 2/3] cpuGetModels: Fix memory leak on error

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

 



Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/cpu/cpu_ppc64.c | 4 +++-
 src/cpu/cpu_x86.c   | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
index 364c8ed..1aed984 100644
--- a/src/cpu/cpu_ppc64.c
+++ b/src/cpu/cpu_ppc64.c
@@ -886,8 +886,10 @@ ppc64DriverGetModels(char ***models)
             if (VIR_STRDUP(name, model->name) < 0)
                 goto error;
 
-            if (VIR_APPEND_ELEMENT(*models, nmodels, name) < 0)
+            if (VIR_APPEND_ELEMENT(*models, nmodels, name) < 0) {
+                VIR_FREE(name);
                 goto error;
+            }
         } else {
             nmodels++;
         }
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index b7f1690..c6aacc1 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -2219,8 +2219,10 @@ x86GetModels(char ***models)
             if (VIR_STRDUP(name, model->name) < 0)
                 goto error;
 
-            if (VIR_APPEND_ELEMENT(*models, nmodels, name) < 0)
+            if (VIR_APPEND_ELEMENT(*models, nmodels, name) < 0) {
+                VIR_FREE(name);
                 goto error;
+            }
         } else {
             nmodels++;
         }
-- 
2.8.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]