a41c76
From a271a6a71073253a7dde518a63d5ee4965ee53d8 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <a271a6a71073253a7dde518a63d5ee4965ee53d8@dist-git>
a41c76
From: Jiri Denemark <jdenemar@redhat.com>
a41c76
Date: Tue, 26 May 2020 10:59:05 +0200
a41c76
Subject: [PATCH] cpu_x86: Use glib allocation in virCPUx86GetModels
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit e43e2ff7f5b629f979e56387c4be46f2be251b75)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Message-Id: <1d1d9c9b60f1ea44a2252cb2fbfbf3886ecd245f.1590483392.git.jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/cpu/cpu_x86.c | 10 +---------
a41c76
 1 file changed, 1 insertion(+), 9 deletions(-)
a41c76
a41c76
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
a41c76
index 3711e03b3f..48f36c2bfc 100644
a41c76
--- a/src/cpu/cpu_x86.c
a41c76
+++ b/src/cpu/cpu_x86.c
a41c76
@@ -3121,21 +3121,13 @@ virCPUx86GetModels(char ***models)
a41c76
         return -1;
a41c76
 
a41c76
     if (models) {
a41c76
-        if (VIR_ALLOC_N(*models, map->nmodels + 1) < 0)
a41c76
-            goto error;
a41c76
+        *models = g_new0(char *, map->nmodels + 1);
a41c76
 
a41c76
         for (i = 0; i < map->nmodels; i++)
a41c76
             (*models)[i] = g_strdup(map->models[i]->name);
a41c76
     }
a41c76
 
a41c76
     return map->nmodels;
a41c76
-
a41c76
- error:
a41c76
-    if (models) {
a41c76
-        virStringListFree(*models);
a41c76
-        *models = NULL;
a41c76
-    }
a41c76
-    return -1;
a41c76
 }
a41c76
 
a41c76
 
a41c76
-- 
a41c76
2.26.2
a41c76