]> git.proxmox.com Git - mirror_qemu.git/commitdiff
vnc: fix segmentation fault when invalid vnc parameters are specified
authorGonglei <arei.gonglei@huawei.com>
Thu, 12 Mar 2015 07:33:45 +0000 (15:33 +0800)
committerGerd Hoffmann <kraxel@redhat.com>
Thu, 12 Mar 2015 08:09:10 +0000 (09:09 +0100)
Reproducer:
 #./qemu-system-x86_64 -vnc :0,ip
qemu-system-x86_64: -vnc :1,ip: Invalid parameter 'ip'
Segmentation fault (core dumped)

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
ui/vnc.c

index 1e95445c4a22c65e10a05a3abd3a5765050f0935..6f9b718814b89c318c1d3e9a04f1fa0257117558 100644 (file)
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3703,8 +3703,13 @@ QemuOpts *vnc_parse_func(const char *str)
 {
     QemuOptsList *olist = qemu_find_opts("vnc");
     QemuOpts *opts = qemu_opts_parse(olist, str, 1);
-    const char *id = qemu_opts_id(opts);
+    const char *id;
 
+    if (!opts) {
+        return NULL;
+    }
+
+    id = qemu_opts_id(opts);
     if (!id) {
         /* auto-assign id if not present */
         vnc_auto_assign_id(olist, opts);