]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qemu-img: Fix segmentation fault
authorCharles Arnold <carnold@suse.com>
Fri, 11 May 2012 16:57:54 +0000 (10:57 -0600)
committerKevin Wolf <kwolf@redhat.com>
Mon, 14 May 2012 15:02:19 +0000 (17:02 +0200)
The following command generates a segmentation fault.
qemu-img convert -O vpc -o ? test test2
This is because the 'goto out;' statement calls qemu_progress_end
before qemu_progress_init is called resulting in a NULL pointer
invocation.

Signed-off-by: Charles Arnold <carnold@suse.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qemu-img.c

index 5434ddc5ee22380e5da9eba9d8c1e71f3bf9d949..c8a70ffc935daee2cc91a99a562075389aa4c6db 100644 (file)
@@ -712,6 +712,9 @@ static int img_convert(int argc, char **argv)
 
     out_filename = argv[argc - 1];
 
+    /* Initialize before goto out */
+    qemu_progress_init(progress, 2.0);
+
     if (options && !strcmp(options, "?")) {
         ret = print_block_option_help(out_filename, out_fmt);
         goto out;
@@ -724,7 +727,6 @@ static int img_convert(int argc, char **argv)
         goto out;
     }
 
-    qemu_progress_init(progress, 2.0);
     qemu_progress_print(0, 100);
 
     bs = g_malloc0(bs_n * sizeof(BlockDriverState *));