[PATCH] string: Fix memory leak in argz-addsep.c

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Fri Jun 26 12:51:25 GMT 2026


I will install this on master, thanks for working on this.

On 26/06/26 04:48, SAMKO wrote:
> Yes, please. Since I do not have commit access, I would greatly appreciate it if you could push this for me.
> Thank you both for your time and the review.
> 
> On Fri, Jun 26, 2026 at 3:58 AM Andreas K. Huettel <dilfridge@gentoo.org <mailto:dilfridge@gentoo.org>> wrote:
> 
>     Am Dienstag, 23. Juni 2026, 01:16:17 Japanische Normalzeit schrieb Adhemerval Zanella Netto:
>     >
>     > On 19/06/26 10:11, Samuel Balazi wrote:
>     > > Assign the realloc result to a temporary variable, so the original
>     > > memory block is not lost if the allocation fails.
>     >
>     > LGTM, thanks.
>     >
>     > Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org <mailto:adhemerval.zanella@linaro.org>>
> 
>     OK (do you need help pushing it?)
> 
>     >
>     > > ---
>     > >  string/argz-addsep.c | 6 ++++--
>     > >  1 file changed, 4 insertions(+), 2 deletions(-)
>     > >
>     > > diff --git a/string/argz-addsep.c b/string/argz-addsep.c
>     > > index 509559dee4..a077d9c7c0 100644
>     > > --- a/string/argz-addsep.c
>     > > +++ b/string/argz-addsep.c
>     > > @@ -30,10 +30,12 @@ __argz_add_sep (char **argz, size_t *argz_len, const char *string, int delim)
>     > >      {
>     > >        const char *rp;
>     > >        char *wp;
>     > > +      char *tmp_argz;
>     > > 
>     > > -      *argz = (char *) realloc (*argz, *argz_len + nlen);
>     > > -      if (*argz == NULL)
>     > > +      tmp_argz = (char *) realloc (*argz, *argz_len + nlen);
>     > > +      if (tmp_argz == NULL)
>     > >     return ENOMEM;
>     > > +      *argz = tmp_argz;
>     > > 
>     > >        wp = *argz + *argz_len;
>     > >        rp = string;
>     >
>     >
> 
> 
>     -- 
>     PD Dr. Andreas K. Hüttel
>     dilfridge@gentoo.org <mailto:dilfridge@gentoo.org>
>     Gentoo Linux developer
>     (council, comrel, toolchain, base-system, perl, libreoffice)
>     https://wiki.gentoo.org/wiki/User:Dilfridge <https://wiki.gentoo.org/wiki/User:Dilfridge>
> 



More information about the Libc-alpha mailing list