From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: KAction@gnu.org Newsgroups: gmane.lisp.guile.devel Subject: [PATCH 1/2] Fix memory leak on `realloc' failure Date: Thu, 10 Apr 2014 09:37:45 +0400 Message-ID: <1397108266-18581-1-git-send-email-KAction@gnu.org> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1397108304 447 80.91.229.3 (10 Apr 2014 05:38:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 10 Apr 2014 05:38:24 +0000 (UTC) Cc: Dmitry Bogatov To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Apr 10 07:38:20 2014 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WY7go-0003OB-Tx for guile-devel@m.gmane.org; Thu, 10 Apr 2014 07:38:19 +0200 Original-Received: from localhost ([::1]:49168 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WY7go-0003PM-CA for guile-devel@m.gmane.org; Thu, 10 Apr 2014 01:38:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WY7ge-0003PE-Mq for guile-devel@gnu.org; Thu, 10 Apr 2014 01:38:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WY7gZ-0003rO-8Z for guile-devel@gnu.org; Thu, 10 Apr 2014 01:38:08 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:57868) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WY7gZ-0003rK-5R for guile-devel@gnu.org; Thu, 10 Apr 2014 01:38:03 -0400 Original-Received: from [195.154.167.241] (port=55047 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1WY7gX-000376-8g; Thu, 10 Apr 2014 01:38:02 -0400 X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::e X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:17045 Archived-At: From: Dmitry Bogatov Signed-off-by: Dmitry Bogatov --- libguile/script.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libguile/script.c b/libguile/script.c index 052ab8d..7b737f7 100644 --- a/libguile/script.c +++ b/libguile/script.c @@ -247,7 +247,10 @@ script_read_arg (FILE *f) size = (size + 1) * 2; buf = realloc (buf, size); if (! buf) - return 0; + { + free (buf); + return 0; + } } buf[len++] = c; break; @@ -330,7 +333,10 @@ scm_get_meta_args (int argc, char **argv) while ((narg = script_read_arg (f))) if (!(nargv = (char **) realloc (nargv, (1 + ++nargc) * sizeof (char *)))) + { + free (nargv); return 0L; + } else nargv[nargi++] = narg; fclose (f); -- Please keep me CC.