From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Linas Vepstas Newsgroups: gmane.lisp.guile.user Subject: [PATCH 3/12] Guile-DBI: Fix memory leak Date: Fri, 19 Sep 2008 09:06:23 -0500 Message-ID: <20080919140623.GC13684@linas.org> References: <3ae3aa420809190645o2fe2b746id80f53c5cb123e5b@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="vEao7xgI/oilGqZ+" X-Trace: ger.gmane.org 1221833425 4702 80.91.229.12 (19 Sep 2008 14:10:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Sep 2008 14:10:25 +0000 (UTC) Cc: Guile User Mailing List To: Maurizio Boriani Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Sep 19 16:11:19 2008 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Kggfu-00048A-08 for guile-user@m.gmane.org; Fri, 19 Sep 2008 16:09:34 +0200 Original-Received: from localhost ([127.0.0.1]:48482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kgger-0006TS-Lv for guile-user@m.gmane.org; Fri, 19 Sep 2008 10:08:29 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kggd1-0005vU-6M for guile-user@gnu.org; Fri, 19 Sep 2008 10:06:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kggcx-0005u6-C5 for guile-user@gnu.org; Fri, 19 Sep 2008 10:06:34 -0400 Original-Received: from [199.232.76.173] (port=57100 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kggcx-0005u0-8m for guile-user@gnu.org; Fri, 19 Sep 2008 10:06:31 -0400 Original-Received: from wf-out-1314.google.com ([209.85.200.175]:31377) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kggcw-0003aT-9N for guile-user@gnu.org; Fri, 19 Sep 2008 10:06:31 -0400 Original-Received: by wf-out-1314.google.com with SMTP id 28so609833wfc.24 for ; Fri, 19 Sep 2008 07:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to:user-agent:from; bh=LlF3vWTmrSiz9Y+Of3lZyFvTsKFOtTvj7TucmVZT2NQ=; b=Sd5AZz4kmwUv2h2/mrdVTCyUgHtmvy5pOEXIM/Xp5S+OOHY+M/SunR7q45qSkwU49O rQSr4UzhQl0bEe/4llCE9rQ9+MwUIBHtw0EQsZ7avJDSFG7l+9WT/Ou8DldqRmk2pKDW mz4rVCCsIK2Jgtk91P4EhsRQf7YGyz/GZ7EMU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:to:cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:from; b=WKLYgR+fSpiULRj7+3BCtkbhoGoTAkSMxzZs9v+5fIphlCe9PFtwYE/85Rpx8PZlq0 eK9bx7sqN756FXMiaDtWq5sSbWXkYhbZ76e4aZassK1HiuaVE+4rd95WebL4lRCfaUEw 6OkuuSghyxz4kzQ+uAnWKiIg+8hRC2hPN8qRY= Original-Received: by 10.114.150.1 with SMTP id x1mr158010wad.71.1221833187106; Fri, 19 Sep 2008 07:06:27 -0700 (PDT) Original-Received: from linas.org ( [67.100.217.179]) by mx.google.com with ESMTPS id 9sm1099116yxs.5.2008.09.19.07.06.26 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 19 Sep 2008 07:06:26 -0700 (PDT) Content-Disposition: inline In-Reply-To: <3ae3aa420809190645o2fe2b746id80f53c5cb123e5b@mail.gmail.com> User-Agent: Mutt/1.5.15+20070412 (2007-04-11) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:6785 Archived-At: --vEao7xgI/oilGqZ+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Fix memory leak; various allocated strins are not freed in assorted error paths. Signed-off-by: Linas Vepstas --- src/guile-dbi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) Index: guile-dbi-2.0.0/src/guile-dbi.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- guile-dbi-2.0.0.orig/src/guile-dbi.c 2008-09-16 20:52:25.000000000 -0500 +++ guile-dbi-2.0.0/src/guile-dbi.c 2008-09-16 20:53:13.000000000 -0500 @@ -55,12 +55,13 @@ SCM_DEFINE (make_g_db_handle, "dbi-open" g_db_handle->handle =3D NULL; g_db_handle->db_info =3D NULL; =20 - bcknd_str =3D (char*) gh_scm2newstr(bcknd,NULL); + bcknd_str =3D scm_to_locale_string (bcknd); =20 sodbd=3D(char*) malloc (sizeof(char)*(strlen("libguile-dbd-") + strlen(bcknd_str) + 10)); if (sodbd =3D=3D NULL) { + free(bcknd_str); g_db_handle->status =3D scm_cons(scm_from_int(errno), scm_makfrom0str(strerror(errno))); SCM_RETURN_NEWSMOB (g_db_handle_tag, g_db_handle); @@ -70,6 +71,8 @@ SCM_DEFINE (make_g_db_handle, "dbi-open" g_db_handle->handle =3D dlopen(sodbd,RTLD_NOW); if ( g_db_handle->handle =3D=3D NULL) { + free(bcknd_str); + free(sodbd); g_db_handle->status =3D scm_cons(scm_from_int(1), scm_makfrom0str(dlerror())); =20 SCM_RETURN_NEWSMOB (g_db_handle_tag, g_db_handle); @@ -78,6 +81,8 @@ SCM_DEFINE (make_g_db_handle, "dbi-open" __gdbi_dbd_wrap(g_db_handle,(char*) __FUNCTION__,(void**) &connect); =20 if (scm_equal_p (SCM_CAR(g_db_handle->status),scm_from_int(0)) =3D=3D SC= M_BOOL_F) { + free(bcknd_str); + free(sodbd); SCM_RETURN_NEWSMOB (g_db_handle_tag, g_db_handle); } =20 --vEao7xgI/oilGqZ+ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iQEVAwUBSNOx34SDRXfAOJJBAQJ+jQgAyck72L4XdYY0Cy5tvIp69xOvrcmxFwHC twRCGG9sfKOXtoOco9p9JMQWYiPR+hgOOGX/2RyDycBvnUA5HiQpI5jrt3Y4pb6p klst2vkTM9ycAFqE9vRonFK+lcsNipzvD5bqRJaYAc8e+107IYS0d6+u4JiVopvi 5cRu57YFH/lo8kfJjmQhgBHT1nnF3kHbbMXW6CfB6y7Vz+LZDbQGwEjShbIHtw+s 6ziolmHnYLMr5gbRZUYLK0KN/FYeH8klwv0LhwauKcJb9amOi+sMAEE7V+6e8PZt Efk+n4Zyx6mP72zvH0/p5CxBL2kYVnscrFtPByoHQNoydviOeCIpWw== =F89r -----END PGP SIGNATURE----- --vEao7xgI/oilGqZ+--