unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH 1/2] Fix memory leak on `realloc' failure
@ 2014-04-10  5:37 KAction
  2014-04-10  5:37 ` [PATCH 2/2] Reduce scope of variables KAction
  2014-04-10 16:36 ` [PATCH 1/2] Fix memory leak on `realloc' failure dsmich
  0 siblings, 2 replies; 6+ messages in thread
From: KAction @ 2014-04-10  5:37 UTC (permalink / raw)
  To: guile-devel; +Cc: Dmitry Bogatov

From: Dmitry Bogatov <KAction@gnu.org>

Signed-off-by: Dmitry Bogatov <KAction@gnu.org>
---
 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.




^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-04-22 20:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-10  5:37 [PATCH 1/2] Fix memory leak on `realloc' failure KAction
2014-04-10  5:37 ` [PATCH 2/2] Reduce scope of variables KAction
2014-04-10 16:36 ` [PATCH 1/2] Fix memory leak on `realloc' failure dsmich
2014-04-10 16:52   ` Dmitry Bogatov
2014-04-12  6:59     ` Dmitry Bogatov
2014-04-22 20:25       ` Andy Wingo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).