Fix potential memory leak in argz_replace

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
David Stacey 2015-05-27 12:08:29 +02:00 committed by Corinna Vinschen
parent ecfe018c65
commit 3710583ebb
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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;