x86/cpuid: Fix crash on -cpu ""
Spotted by Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 99cff65..21e5896 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -594,9 +594,9 @@
uint32_t numvalue;
for (def = x86_defs; def; def = def->next)
- if (!strcmp(name, def->name))
+ if (name && !strcmp(name, def->name))
break;
- if (kvm_enabled() && strcmp(name, "host") == 0) {
+ if (kvm_enabled() && name && strcmp(name, "host") == 0) {
cpu_x86_fill_host(x86_cpu_def);
} else if (!def) {
goto error;