Commit 96bc97eb authored by Markus Armbruster's avatar Markus Armbruster Committed by Anthony Liguori
Browse files

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: default avatarMarkus Armbruster <armbru@redhat.com>
Reviewed-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Message-id: 1372943363-24081-2-git-send-email-armbru@redhat.com
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
parent 154bb106
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -706,17 +706,13 @@ QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id)
    QemuOpts *opts;

    QTAILQ_FOREACH(opts, &list->head, next) {
        if (!opts->id) {
            if (!id) {
        if (!opts->id && !id) {
            return opts;
        }
            continue;
        }
        if (strcmp(opts->id, id) != 0) {
            continue;
        }
        if (opts->id && id && !strcmp(opts->id, id)) {
            return opts;
        }
    }
    return NULL;
}