diff options
author | Kevin Wolf <kwolf@redhat.com> | 2009-11-27 17:35:55 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-12-03 11:45:50 -0600 |
commit | 702ef63f3e0ba569727a8e01db0ef2c7cbff36e9 (patch) | |
tree | 782f92850a9f4db24f3a8674b1b1fa8f9d4c7203 /block/qcow2-refcount.c | |
parent | e1c7f0e3f998866bedc9bdb53d247859b7beb5ce (diff) |
qcow2: Fix some more qemu_malloc fallout
Oh joy...
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'block/qcow2-refcount.c')
-rw-r--r-- | block/qcow2-refcount.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 30266786df..54b19f86dd 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -513,7 +513,11 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs, l1_size2 = l1_size * sizeof(uint64_t); l1_allocated = 0; if (l1_table_offset != s->l1_table_offset) { - l1_table = qemu_mallocz(align_offset(l1_size2, 512)); + if (l1_size2 != 0) { + l1_table = qemu_mallocz(align_offset(l1_size2, 512)); + } else { + l1_table = NULL; + } l1_allocated = 1; if (bdrv_pread(s->hd, l1_table_offset, l1_table, l1_size2) != l1_size2) @@ -769,12 +773,16 @@ static int check_refcounts_l1(BlockDriverState *bs, l1_table_offset, l1_size2); /* Read L1 table entries from disk */ - l1_table = qemu_malloc(l1_size2); - if (bdrv_pread(s->hd, l1_table_offset, - l1_table, l1_size2) != l1_size2) - goto fail; - for(i = 0;i < l1_size; i++) - be64_to_cpus(&l1_table[i]); + if (l1_size2 == 0) { + l1_table = NULL; + } else { + l1_table = qemu_malloc(l1_size2); + if (bdrv_pread(s->hd, l1_table_offset, + l1_table, l1_size2) != l1_size2) + goto fail; + for(i = 0;i < l1_size; i++) + be64_to_cpus(&l1_table[i]); + } /* Do the actual checks */ for(i = 0; i < l1_size; i++) { |