Am 06.12.2010 16:45, schrieb jes.soren...@redhat.com:
> From: Jes Sorensen <jes.soren...@redhat.com>
> 
> Signed-off-by: Jes Sorensen <jes.soren...@redhat.com>
> ---
>  qemu-img.c |   14 +++++++++-----
>  1 files changed, 9 insertions(+), 5 deletions(-)

> @@ -1432,7 +1434,7 @@ static int img_resize(int argc, char **argv)
>      int c, ret, relative;
>      const char *filename, *fmt, *size;
>      int64_t n, total_size;
> -    BlockDriverState *bs;
> +    BlockDriverState *bs = NULL;
>      QEMUOptionParameter *param;
>      QEMUOptionParameter resize_options[] = {
>          {
> @@ -1483,14 +1485,16 @@ static int img_resize(int argc, char **argv)
>      param = parse_option_parameters("", resize_options, NULL);
>      if (set_option_parameter(param, BLOCK_OPT_SIZE, size)) {
>          /* Error message already printed when size parsing fails */
> -        exit(1);
> +        ret = -1;
> +        goto out;
>      }
>      n = get_option_parameter(param, BLOCK_OPT_SIZE)->value.n;
>      free_option_parameters(param);
>  
>      bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR);
>      if (!bs) {
> -        return 1;
> +        ret = -1;
> +        goto out;
>      }
>  
>      if (relative) {

bdrv_delete doesn't check for NULL, so this still isn't enough. Try
something like "qemu-img resize -f vmdx foo +0" and you'll get a segfault.

Kevin

Reply via email to