From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btybb-0005iX-UM for qemu-devel@nongnu.org; Tue, 11 Oct 2016 11:04:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btybW-00077D-R9 for qemu-devel@nongnu.org; Tue, 11 Oct 2016 11:04:34 -0400 References: <1476105837-9861-1-git-send-email-eblake@redhat.com> <1476105837-9861-9-git-send-email-eblake@redhat.com> From: Eric Blake Message-ID: <0863ea02-6595-36f0-ca8e-6f00b6f94b54@redhat.com> Date: Tue, 11 Oct 2016 10:04:18 -0500 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="E2NB80VV1h7HSS0e5sN7gKe1JHUXpkNW0" Subject: Re: [Qemu-devel] [PATCH v6 08/15] qstring: Add qstring_wrap_str() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= , qemu-devel@nongnu.org Cc: Kevin Wolf , Chrysostomos Nanakos , "open list:Block layer core" , Jeff Cody , armbru@redhat.com, Max Reitz This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --E2NB80VV1h7HSS0e5sN7gKe1JHUXpkNW0 From: Eric Blake To: =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= , qemu-devel@nongnu.org Cc: Kevin Wolf , Chrysostomos Nanakos , "open list:Block layer core" , Jeff Cody , armbru@redhat.com, Max Reitz Message-ID: <0863ea02-6595-36f0-ca8e-6f00b6f94b54@redhat.com> Subject: Re: [Qemu-devel] [PATCH v6 08/15] qstring: Add qstring_wrap_str() References: <1476105837-9861-1-git-send-email-eblake@redhat.com> <1476105837-9861-9-git-send-email-eblake@redhat.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/11/2016 06:08 AM, Marc-Andr=C3=A9 Lureau wrote: >> +++ b/block.c >> @@ -1640,7 +1640,8 @@ static BlockDriverState >> *bdrv_append_temp_snapshot(BlockDriverState *bs, >> qdict_put(snapshot_options, "file.driver", >> qstring_from_str("file")); >> qdict_put(snapshot_options, "file.filename", >> - qstring_from_str(tmp_filename)); >> + qstring_wrap_str(tmp_filename)); >> + tmp_filename =3D NULL; >> qdict_put(snapshot_options, "driver", >> qstring_from_str("qcow2")); >> >> > You could also remove g_free(tmp_filename) from the normal return path > (this may please static analyzers). No. g_free(NULL) is safe, but we can also reach the 'out' label with tmp_filename still malloc'd prior to the place where we transfer it here, so the g_free() in the cleanup label is still required. The assignment to NULL here prevents a double free. The patch is correct as-= is. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --E2NB80VV1h7HSS0e5sN7gKe1JHUXpkNW0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJX/P9yAAoJEKeha0olJ0Nq2z4H/2lOZSdm77u6rdAAiOgNm60F SyRFfAr177vSzjaXFc5DEeBA71eLUBkiLX89qrb2ZHL2ODdEgji90GkJ8F5qVnwa 2e8STaz0WUQ1i9kov2cw5pTTGuicOf9Ha8XmoCxzctj6dZJAi2AKAhdMP5ho27YC bN0eRFhkentD2FrMD72kydBVxA2C0t98NvcVcJIFsawSIk/Flf8hAU8h250H12dO N+q24MBK6IQz6MydXoIzVhXU93gv8RstgxLGSyZY5jquxgJqKMtoejY93bGKvOBG oaM3JcBln1RwnyR6pFBKqxniL+I6zJlyg8SYmP0FH12h8ovCXjcEhBj73aoU/rg= =t0YM -----END PGP SIGNATURE----- --E2NB80VV1h7HSS0e5sN7gKe1JHUXpkNW0--