x86/cpuid: Plug memory leak in cpudef_setfield()
authorMarkus Armbruster <armbru@redhat.com>
Tue, 8 Nov 2011 14:36:49 +0000 (15:36 +0100)
committerStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Thu, 10 Nov 2011 12:29:50 +0000 (12:29 +0000)
To reproduce the leak, put two name options into the same [cpudef]
section of target-x86_64.conf.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
target-i386/cpuid.c

index 352c390d0c6fce203c86b0d9cce362b22f15c5b2..99cff65aae4d47cd7ad7d637f1c35f5ae5adddfe 100644 (file)
@@ -950,6 +950,7 @@ static int cpudef_setfield(const char *name, const char *str, void *opaque)
     int err = 0;
 
     if (!strcmp(name, "name")) {
+        g_free((void *)def->name);
         def->name = g_strdup(str);
     } else if (!strcmp(name, "model_id")) {
         strncpy(def->model_id, str, sizeof (def->model_id));