From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDdg0-0006SJ-1J for qemu-devel@nongnu.org; Tue, 20 Jan 2015 13:37:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDdfv-000466-Ia for qemu-devel@nongnu.org; Tue, 20 Jan 2015 13:37:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41550) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDdfv-00045y-AN for qemu-devel@nongnu.org; Tue, 20 Jan 2015 13:37:15 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0KIbEjZ024366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 20 Jan 2015 13:37:14 -0500 Message-ID: <54BEA059.8040209@redhat.com> Date: Tue, 20 Jan 2015 13:37:13 -0500 From: John Snow MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 3/6] block: qapi - move string allocation from stack to the heap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody , qemu-devel@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com On 01/20/2015 12:31 PM, Jeff Cody wrote: > Rather than declaring 'backing_filename2' on the stack in > bdrv_quiery_image_info(), dynamically allocate it on the heap. > > Signed-off-by: Jeff Cody > --- > block/qapi.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/block/qapi.c b/block/qapi.c > index a6fd6f7..e51bade 100644 > --- a/block/qapi.c > +++ b/block/qapi.c > @@ -175,7 +175,7 @@ void bdrv_query_image_info(BlockDriverState *bs, > { > int64_t size; > const char *backing_filename; > - char backing_filename2[1024]; > + char *backing_filename2 = NULL; > BlockDriverInfo bdi; > int ret; > Error *err = NULL; > @@ -211,13 +211,14 @@ void bdrv_query_image_info(BlockDriverState *bs, > > backing_filename = bs->backing_file; > if (backing_filename[0] != '\0') { > + 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 +232,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); > Reviewed-by: John Snow