[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.11-5-g7eaa92
From: |
Andy Wingo |
Subject: |
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.11-5-g7eaa92f |
Date: |
Tue, 22 Apr 2014 20:25:01 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".
http://git.savannah.gnu.org/cgit/guile.git/commit/?id=7eaa92ffa9594025d989d5584750b72fe5797c20
The branch, stable-2.0 has been updated
via 7eaa92ffa9594025d989d5584750b72fe5797c20 (commit)
from d2fcbb193b67106d0c0b57cd1e988acf2d30ace7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 7eaa92ffa9594025d989d5584750b72fe5797c20
Author: Dmitry Bogatov <address@hidden>
Date: Thu Apr 10 09:23:28 2014 +0400
Fix memory leak on `realloc' failure
* libguile/script.c (realloc0): New helper.
(script_read_arg, scm_get_meta_args): Use realloc0, not realloc.
Signed-off-by: Dmitry Bogatov <address@hidden>
-----------------------------------------------------------------------
Summary of changes:
libguile/script.c | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/libguile/script.c b/libguile/script.c
index 0d7b28f..b6910ba 100644
--- a/libguile/script.c
+++ b/libguile/script.c
@@ -219,6 +219,21 @@ script_get_backslash (FILE *f)
}
#undef FUNC_NAME
+/*
+ * Like `realloc', but free memory on failure;
+ * unlike `scm_realloc', return NULL, not aborts.
+*/
+static void*
+realloc0 (void *ptr, size_t size)
+{
+ void *new_ptr = realloc (ptr, size);
+ if (!new_ptr)
+ {
+ free (ptr);
+ }
+ return new_ptr;
+}
+
static char *
script_read_arg (FILE *f)
@@ -244,7 +259,7 @@ script_read_arg (FILE *f)
if (len >= size)
{
size = (size + 1) * 2;
- buf = realloc (buf, size);
+ buf = realloc0 (buf, size);
if (! buf)
return 0;
}
@@ -327,9 +342,9 @@ scm_get_meta_args (int argc, char **argv)
found_args:
/* FIXME: we leak the result of calling script_read_arg. */
while ((narg = script_read_arg (f)))
- if (!(nargv = (char **) realloc (nargv,
+ if (!(nargv = (char **) realloc0 (nargv,
(1 + ++nargc) * sizeof (char *))))
- return 0L;
+ return 0L;
else
nargv[nargi++] = narg;
fclose (f);
hooks/post-receive
--
GNU Guile
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.11-5-g7eaa92f,
Andy Wingo <=