diff options
author | Markus Armbruster <armbru@redhat.com> | 2013-07-04 15:09:17 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-07-09 13:38:56 -0500 |
commit | 96bc97ebf350ec480b69082819cedb8850f46a0f (patch) | |
tree | ad28c35f205d8eb1d85b021664a4711ccc0889cd | |
parent | 154bb106dc195b4fbb76df0452ab6e3e24e80d72 (diff) | |
download | qemu-96bc97ebf350ec480b69082819cedb8850f46a0f.zip qemu-96bc97ebf350ec480b69082819cedb8850f46a0f.tar.gz qemu-96bc97ebf350ec480b69082819cedb8850f46a0f.tar.bz2 |
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 <armbru@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1372943363-24081-2-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | util/qemu-option.c | 12 |
1 files changed, 4 insertions, 8 deletions
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; } |