aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2016-03-08 16:24:35 +0800
committerKevin Wolf <kwolf@redhat.com>2016-03-14 16:46:43 +0100
commit5997c210b9ed7d6dbc64aa5049eb2bc4ec574aba (patch)
tree857e4e93639f413fd08a2eb1683de1d86bef0a19 /block
parent965415eb20b8f2252289166da1bc6e488b466873 (diff)
vmdk: Switch to heap arrays for vmdk_read_cid
Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/vmdk.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/block/vmdk.c b/block/vmdk.c
index 1ec2452da5..c68f4563ad 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -242,15 +242,17 @@ static void vmdk_free_last_extent(BlockDriverState *bs)
static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent)
{
- char desc[DESC_SIZE];
+ char *desc;
uint32_t cid = 0xffffffff;
const char *p_name, *cid_str;
size_t cid_str_size;
BDRVVmdkState *s = bs->opaque;
int ret;
+ desc = g_malloc0(DESC_SIZE);
ret = bdrv_pread(bs->file->bs, s->desc_offset, desc, DESC_SIZE);
if (ret < 0) {
+ g_free(desc);
return 0;
}
@@ -269,6 +271,7 @@ static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent)
sscanf(p_name, "%" SCNx32, &cid);
}
+ g_free(desc);
return cid;
}