From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com
Subject: [Qemu-devel] [PULL 07/12] block: qapi - move string allocation from stack to the heap
Date: Fri, 23 Jan 2015 19:20:13 +0100 [thread overview]
Message-ID: <1422037218-31855-8-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1422037218-31855-1-git-send-email-kwolf@redhat.com>
From: Jeff Cody <jcody@redhat.com>
Rather than declaring 'backing_filename2' on the stack in
bdrv_query_image_info(), dynamically allocate it on the heap.
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
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.8.3.1
next prev parent reply other threads:[~2015-01-23 18:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-23 18:20 [Qemu-devel] [PULL 00/12] Block patches Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 01/12] virtio-blk: Pass req to virtio_blk_handle_scsi_req Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 02/12] virtio-blk: Use blk_aio_ioctl Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 03/12] qcow2: Add two more unalignment checks Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 04/12] iotests: Add tests for more corruption cases Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 05/12] block: vmdk - make ret variable usage clear Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 06/12] block: vmdk - move string allocations from stack to the heap Kevin Wolf
2015-01-23 18:20 ` Kevin Wolf [this message]
2015-01-23 18:20 ` [Qemu-devel] [PULL 08/12] block: remove unused variable in bdrv_commit Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 09/12] block: mirror - change string allocation to 2-bytes Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 10/12] block: update string sizes for filename, backing_file, exact_filename Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 11/12] block: vhdx - force FileOffsetMB field to '0' for certain block states Kevin Wolf
2015-01-23 18:20 ` [Qemu-devel] [PULL 12/12] iotests: Lower 064's memory usage Kevin Wolf
2015-01-26 10:16 ` [Qemu-devel] [PULL 00/12] Block patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1422037218-31855-8-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).