[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 3/6] block: qapi - move string allocation from st
From: |
Jeff Cody |
Subject: |
[Qemu-devel] [PATCH v3 3/6] block: qapi - move string allocation from stack to the heap |
Date: |
Thu, 22 Jan 2015 08:03:27 -0500 |
Rather than declaring 'backing_filename2' on the stack in
bdrv_query_image_info(), dynamically allocate it on the heap.
Reviewed-by: John Snow <address@hidden>
Signed-off-by: Jeff Cody <address@hidden>
---
block/qapi.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/block/qapi.c b/block/qapi.c
index a6fd6f7..dec9f60 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -175,7 +175,6 @@ void bdrv_query_image_info(BlockDriverState *bs,
{
int64_t size;
const char *backing_filename;
- char backing_filename2[1024];
BlockDriverInfo bdi;
int ret;
Error *err = NULL;
@@ -211,13 +210,14 @@ void bdrv_query_image_info(BlockDriverState *bs,
backing_filename = bs->backing_file;
if (backing_filename[0] != '\0') {
+ char *backing_filename2 = g_malloc0(1024);
info->backing_filename = g_strdup(backing_filename);
info->has_backing_filename = true;
- bdrv_get_full_backing_filename(bs, backing_filename2,
- sizeof(backing_filename2), &err);
+ bdrv_get_full_backing_filename(bs, backing_filename2, 1024, &err);
if (err) {
error_propagate(errp, err);
qapi_free_ImageInfo(info);
+ g_free(backing_filename2);
return;
}
@@ -231,6 +231,7 @@ void bdrv_query_image_info(BlockDriverState *bs,
info->backing_filename_format = g_strdup(bs->backing_format);
info->has_backing_filename_format = true;
}
+ g_free(backing_filename2);
}
ret = bdrv_query_snapshot_info_list(bs, &info->snapshots, &err);
--
1.9.3
- [Qemu-devel] [PATCH v3 0/6] Update filename string sizes in block layer, Jeff Cody, 2015/01/22
- [Qemu-devel] [PATCH v3 1/6] block: vmdk - make ret variable usage clear, Jeff Cody, 2015/01/22
- [Qemu-devel] [PATCH v3 2/6] block: vmdk - move string allocations from stack to the heap, Jeff Cody, 2015/01/22
- [Qemu-devel] [PATCH v3 3/6] block: qapi - move string allocation from stack to the heap,
Jeff Cody <=
- [Qemu-devel] [PATCH v3 5/6] block: mirror - change string allocation to 2-bytes, Jeff Cody, 2015/01/22
- [Qemu-devel] [PATCH v3 4/6] block: remove unused variable in bdrv_commit, Jeff Cody, 2015/01/22
- [Qemu-devel] [PATCH v3 6/6] block: update string sizes for filename, backing_file, exact_filename, Jeff Cody, 2015/01/22
- Re: [Qemu-devel] [PATCH v3 0/6] Update filename string sizes in block layer, Kevin Wolf, 2015/01/23