From 702ef63f3e0ba569727a8e01db0ef2c7cbff36e9 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Fri, 27 Nov 2009 17:35:55 +0100 Subject: qcow2: Fix some more qemu_malloc fallout Oh joy... Signed-off-by: Kevin Wolf Signed-off-by: Anthony Liguori --- block/qcow2-snapshot.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'block/qcow2-snapshot.c') diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 94cb838064..d63c7e17d8 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -266,7 +266,12 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) sn->l1_table_offset = qcow2_alloc_clusters(bs, s->l1_size * sizeof(uint64_t)); sn->l1_size = s->l1_size; - l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t)); + if (s->l1_size != 0) { + l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t)); + } else { + l1_table = NULL; + } + for(i = 0; i < s->l1_size; i++) { l1_table[i] = cpu_to_be64(s->l1_table[i]); } -- cgit v1.2.3