提交 96bc97eb 编写于 作者: M Markus Armbruster 提交者: Anthony Liguori

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: NMarkus Armbruster <armbru@redhat.com>
Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
Message-id: 1372943363-24081-2-git-send-email-armbru@redhat.com
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 154bb106
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册