From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEFsg-0000wI-7P for qemu-devel@nongnu.org; Thu, 22 Jan 2015 06:24:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEFsc-0002lh-Sd for qemu-devel@nongnu.org; Thu, 22 Jan 2015 06:24:58 -0500 Received: from mail-wg0-x230.google.com ([2a00:1450:400c:c00::230]:62747) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEFsc-0002lP-Kf for qemu-devel@nongnu.org; Thu, 22 Jan 2015 06:24:54 -0500 Received: by mail-wg0-f48.google.com with SMTP id x12so1131913wgg.7 for ; Thu, 22 Jan 2015 03:24:54 -0800 (PST) Date: Thu, 22 Jan 2015 11:24:45 +0000 From: Stefan Hajnoczi Message-ID: <20150122112445.GC28491@stefanha-thinkpad.redhat.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="gr/z0/N6AeWAPJVB" Content-Disposition: inline In-Reply-To: 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 Cc: kwolf@redhat.com, jsnow@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com --gr/z0/N6AeWAPJVB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jan 20, 2015 at 12:31:30PM -0500, Jeff Cody wrote: > Rather than declaring 'backing_filename2' on the stack in > bdrv_quiery_image_info(), dynamically allocate it on the heap. s/quiery/query/ >=20 > Signed-off-by: Jeff Cody > --- > block/qapi.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) >=20 > 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 =3D NULL; > BlockDriverInfo bdi; > int ret; > Error *err =3D NULL; > @@ -211,13 +211,14 @@ void bdrv_query_image_info(BlockDriverState *bs, > =20 > backing_filename =3D bs->backing_file; > if (backing_filename[0] !=3D '\0') { > + backing_filename2 =3D g_malloc0(1024); backing_filename2 is only used inside the body of this if statement. Please move the declaration in here to avoid initializing with NULL (that value is never used but I had to check the surrounding code to figure that out). --gr/z0/N6AeWAPJVB Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUwN39AAoJEJykq7OBq3PIDOIH/1emPQ9RbVvEoj/dFRQaaWIx RdAfk0bnZ59tg0+WDFzFhO+mavzIEQOqiVA/sTKaw9CwRvk2rCNFQGYENJ6MvB6P W32BuPXoLpPzzg7eDCbJ1WWCUW6MaHPMJOfZ5JxGZRESaFIoFTJ3br+YDdnmv4cr teww0jg6w/qe4cLYp6sgKN3EYFPa9Cc9RcheKn7+B0bOHunbVo+4RfCrn0t1jII8 lvKvrh8y0hZKhCW7xboICB9p7aAbINBvWZBjIZqNiRlBCgz6cbyvIhI1hMM7inrM VSV9VnU3DP/uBF4ytzhyp+ALcPfHML/Wy7h9udlWtLja/jQM069Rllx16EgjuWU= =KHiJ -----END PGP SIGNATURE----- --gr/z0/N6AeWAPJVB--