From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btycy-0006Mt-TT for qemu-devel@nongnu.org; Tue, 11 Oct 2016 11:06:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btyct-0007gw-FW for qemu-devel@nongnu.org; Tue, 11 Oct 2016 11:06:00 -0400 References: <1476105837-9861-1-git-send-email-eblake@redhat.com> <1476105837-9861-9-git-send-email-eblake@redhat.com> <0863ea02-6595-36f0-ca8e-6f00b6f94b54@redhat.com> From: Eric Blake Message-ID: <079f22c0-7af3-bb03-eed3-2c956761568e@redhat.com> Date: Tue, 11 Oct 2016 10:05:42 -0500 MIME-Version: 1.0 In-Reply-To: <0863ea02-6595-36f0-ca8e-6f00b6f94b54@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="RTw1CUQ88wbEmImEtafXnewEHPwtrVFjJ" 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) --RTw1CUQ88wbEmImEtafXnewEHPwtrVFjJ 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: <079f22c0-7af3-bb03-eed3-2c956761568e@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> <0863ea02-6595-36f0-ca8e-6f00b6f94b54@redhat.com> In-Reply-To: <0863ea02-6595-36f0-ca8e-6f00b6f94b54@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/11/2016 10:04 AM, Eric Blake wrote: > On 10/11/2016 06:08 AM, Marc-Andr=C3=A9 Lureau wrote: >=20 >>> +++ 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). >=20 > 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 a= s-is. Spoke too soon. I see what you're saying - the normal return path now has a dead g_free(NULL). It won't cause any grief to the static analyzers, but it is a useless no-op function call, so I can indeed trim it (the one before the label, not the one after). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --RTw1CUQ88wbEmImEtafXnewEHPwtrVFjJ 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/P/GAAoJEKeha0olJ0NqAAgH/R6gzY7C16teQztiSSt6wv06 rrlVKG7UvuW5yi0DVICCwrmhFiyv1dx3KKsAqApu0XVcOz3Yc9NgLxQ3dp+ieOAZ OhrG977oIpJxrVGAtSsHKOnkbqsCBeeSwj9bNNebz48eyhbq/C8tEFN7sGo8DP1W QmSya9yBeGlTzZahepAeCE4I7niL0As1VQbbFHpNRZ02U72s51Jafzb1cyjkcSjv c3eCYJ4y6U+PmaF+UWsPIpknxcIqul4orLDTaPgW9CIl7XXrQ5Uh2r9RAzVJR92T msfJV0RGAGaRE8DRhGcTw6FaGtgEzQZlRwK2L+z16kbcmyezdHg9KLjE3owlbsY= =txx/ -----END PGP SIGNATURE----- --RTw1CUQ88wbEmImEtafXnewEHPwtrVFjJ--