public inbox for newlib-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: newlib-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-2.0] Fix potential memory leak in argz_replace Date: Wed, 27 May 2015 11:32:00 -0000 [thread overview] Message-ID: <20150527113221.56717.qmail@sourceware.org> (raw) 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;
reply other threads:[~2015-05-27 11:32 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20150527113221.56717.qmail@sourceware.org \ --to=corinna@sourceware.org \ --cc=newlib-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).