Received: from eggs.gnu.org ([140.186.70.92]:33810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QkDwY-0004Y4-86 for qemu-devel@nongnu.org; Fri, 22 Jul 2011 07:30:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QkDwX-0007pB-73 for qemu-devel@nongnu.org; Fri, 22 Jul 2011 07:30:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29721) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QkDwW-0007p5-W5 for qemu-devel@nongnu.org; Fri, 22 Jul 2011 07:30:57 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6MBUtNC002491 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 22 Jul 2011 07:30:55 -0400 Received: from teriyaki.redhat.com (ovpn-116-27.ams2.redhat.com [10.36.116.27]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6MBUoUq001515 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Fri, 22 Jul 2011 07:30:54 -0400 Date: Fri, 22 Jul 2011 13:30:49 +0200 From: Christophe Fergeau Message-ID: <20110722113049.GF8232@teriyaki.redhat.com> References: <1309795843-4969-1-git-send-email-cfergeau@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Pgaa2uWPnPrfixyx" Content-Disposition: inline In-Reply-To: <1309795843-4969-1-git-send-email-cfergeau@redhat.com> Subject: Re: [Qemu-devel] [PATCH] libcacard: don't leak vcard_emul_alloc_arrays mem List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --Pgaa2uWPnPrfixyx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Ping? On Mon, Jul 04, 2011 at 06:10:43PM +0200, Christophe Fergeau wrote: > vcard_emul_mirror_card and vcard_emul_init use > vcard_emul_alloc_arrays to allocate memory for temporary arrays > which will contain elements that in the end will be used one by > one in cac_card_init. The arrays themselves are never stored > anywhere, they are only used as temporary containers. Hence > the memory that was allocated for these arrays should be freed > after use or they will be leaked. > --- > libcacard/vcard_emul_nss.c | 11 ++++++++++- > 1 files changed, 10 insertions(+), 1 deletions(-) >=20 > diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c > index de324ba..4fee471 100644 > --- a/libcacard/vcard_emul_nss.c > +++ b/libcacard/vcard_emul_nss.c > @@ -476,6 +476,7 @@ vcard_emul_mirror_card(VReader *vreader) > VCardKey **keys; > PK11SlotInfo *slot; > PRBool ret; > + VCard *card; > =20 > slot =3D vcard_emul_reader_get_slot(vreader); > if (slot =3D=3D NULL) { > @@ -535,7 +536,12 @@ vcard_emul_mirror_card(VReader *vreader) > } > =20 > /* now create the card */ > - return vcard_emul_make_card(vreader, certs, cert_len, keys, cert_cou= nt); > + card =3D vcard_emul_make_card(vreader, certs, cert_len, keys, cert_c= ount); > + qemu_free(certs); > + qemu_free(cert_len); > + qemu_free(keys); > + > + return card; > } > =20 > static VCardEmulType default_card_type =3D VCARD_EMUL_NONE; > @@ -820,6 +826,9 @@ vcard_emul_init(const VCardEmulOptions *options) > vreader_free(vreader); > has_readers =3D PR_TRUE; > } > + qemu_free(certs); > + qemu_free(cert_len); > + qemu_free(keys); > } > =20 > /* if we aren't suppose to use hw, skip looking up hardware tokens */ > --=20 > 1.7.5.4 >=20 >=20 --Pgaa2uWPnPrfixyx Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk4pX2kACgkQJKRp+3pW946WUgCePw08CADaO/aJS/pBL7sivfF1 1I4AnjwYXXmCiMiEKThwkbQIktCkd4n3 =oQAo -----END PGP SIGNATURE----- --Pgaa2uWPnPrfixyx--