public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/cygwin-2.0] Fix potential memory leak in argz_replace
@ 2015-05-27 11:32 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2015-05-27 11:32 UTC (permalink / raw)
To: newlib-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=ca632c90157aaa0f0e00843bf8501c6831abe84b
commit ca632c90157aaa0f0e00843bf8501c6831abe84b
Author: David Stacey <drstacey@tiscali.co.uk>
Date: Wed May 27 12:08:29 2015 +0200
Fix potential memory leak in argz_replace
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
newlib/ChangeLog | 4 ++++
newlib/libc/argz/argz_replace.c | 5 ++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index a70fefe..d1b0afe 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,7 @@
+2015-05-27 David Stacey <drstacey@tiscali.co.uk>
+
+ * libc/argz/argz_replace.c: Fix potential memory leak.
+
2015-05-26 DJ Delorie <dj@redhat.com>
* libm/math/e_sqrt.c (__ieee754_sqrt): Don't truncate constant to
diff --git a/newlib/libc/argz/argz_replace.c b/newlib/libc/argz/argz_replace.c
index cb01eae..6bfd04b 100644
--- a/newlib/libc/argz/argz_replace.c
+++ b/newlib/libc/argz/argz_replace.c
@@ -71,7 +71,10 @@ _DEFUN (argz_replace, (argz, argz_len, str, with, replace_count),
/* reallocate argz, and copy over the new value. */
if(!(*argz = (char *)realloc(*argz, new_argz_len)))
- return ENOMEM;
+ {
+ free(new_argz);
+ return ENOMEM;
+ }
memcpy(*argz, new_argz, new_argz_len);
*argz_len = new_argz_len;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-05-27 11:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-27 11:32 [newlib-cygwin/cygwin-2.0] Fix potential memory leak in argz_replace Corinna Vinschen
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).