diff options
author | Eduardo Habkost <ehabkost@redhat.com> | 2019-04-18 00:45:01 -0300 |
---|---|---|
committer | Eduardo Habkost <ehabkost@redhat.com> | 2019-04-25 14:17:35 -0300 |
commit | 5b863f3e2fade14ef0be01b2b690aac2c4fab477 (patch) | |
tree | b08da90a3f21044d283749ab0038a5892ca5a3b9 /exec.c | |
parent | c1c8cfe5f983aff0fcb018b0f0a11dd4580cc88e (diff) |
cpu: Fix crash with empty -cpu option
Fix the following crash:
$ qemu-system-x86_64 -cpu ''
qemu-system-x86_64: qom/cpu.c:291: cpu_class_by_name: \
Assertion `cpu_model && cc->class_by_name' failed.
Regression test script included.
Fixes: 99193d8f2ef5 ("cpu: drop unnecessary NULL check and cpu_common_class_by_name()")
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20190418034501.5038-1-ehabkost@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Tested-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'exec.c')
-rw-r--r-- | exec.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -991,6 +991,10 @@ const char *parse_cpu_option(const char *cpu_option) const char *cpu_type; model_pieces = g_strsplit(cpu_option, ",", 2); + if (!model_pieces[0]) { + error_report("-cpu option cannot be empty"); + exit(1); + } oc = cpu_class_by_name(CPU_RESOLVING_TYPE, model_pieces[0]); if (oc == NULL) { |