From: Markus Armbruster Date: Thu, 4 Jul 2013 13:09:17 +0000 (+0200) Subject: qemu-option: Fix qemu_opts_find() for null id arguments X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~1630 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=96bc97ebf350ec480b69082819cedb8850f46a0f;p=sdk%2Femulator%2Fqemu.git qemu-option: Fix qemu_opts_find() for null id arguments Crashes when the first list member has an ID. Admittedly nonsensical reproducer: $ qemu-system-x86_64 -nodefaults -machine id=foo -machine "" Signed-off-by: Markus Armbruster Reviewed-by: Peter Maydell Message-id: 1372943363-24081-2-git-send-email-armbru@redhat.com Signed-off-by: Anthony Liguori --- diff --git a/util/qemu-option.c b/util/qemu-option.c index 412c425..2715f27 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -706,16 +706,12 @@ QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id) QemuOpts *opts; QTAILQ_FOREACH(opts, &list->head, next) { - if (!opts->id) { - if (!id) { - return opts; - } - continue; + if (!opts->id && !id) { + return opts; } - if (strcmp(opts->id, id) != 0) { - continue; + if (opts->id && id && !strcmp(opts->id, id)) { + return opts; } - return opts; } return NULL; }