提交 31ca34b8 编写于 作者: J Jes Sorensen 提交者: Kevin Wolf

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: NJes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 5bdf61fd
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册