diff options
author | Jes Sorensen <Jes.Sorensen@redhat.com> | 2010-12-06 15:25:36 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2010-12-14 15:44:21 +0100 |
commit | 31ca34b8cc2efe1b7e3f726dedb30c450a81abaf (patch) | |
tree | e942d3f2db45fd145d4732674ad7f2745d944e59 /qemu-img.c | |
parent | 5bdf61fdd76b5ca7101353abbdbcd1ed692fa9e2 (diff) | |
download | qemu-31ca34b8cc2efe1b7e3f726dedb30c450a81abaf.zip qemu-31ca34b8cc2efe1b7e3f726dedb30c450a81abaf.tar.gz qemu-31ca34b8cc2efe1b7e3f726dedb30c450a81abaf.tar.bz2 |
img_convert(): Only try to free bs[] entries if bs is valid.
This allows for jumping to 'out:' consistently for error exit.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-img.c')
-rw-r--r-- | qemu-img.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -696,7 +696,8 @@ static int img_convert(int argc, char **argv) if (bs_n > 1 && out_baseimg) { error("-B makes no sense when concatenating multiple input images"); - return 1; + ret = -1; + goto out; } bs = qemu_mallocz(bs_n * sizeof(BlockDriverState *)); @@ -974,12 +975,14 @@ out: if (out_bs) { bdrv_delete(out_bs); } - for (bs_i = 0; bs_i < bs_n; bs_i++) { - if (bs[bs_i]) { - bdrv_delete(bs[bs_i]); + if (bs) { + for (bs_i = 0; bs_i < bs_n; bs_i++) { + if (bs[bs_i]) { + bdrv_delete(bs[bs_i]); + } } + qemu_free(bs); } - qemu_free(bs); if (ret) { return 1; } |