[COMMITED] posix: Fix memory leak a memory leak in glob.

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Wed Oct 22 12:17:21 GMT 2025



On 21/10/25 23:52, Collin Funk wrote:
> From: Bruno Haible <bruno@clisp.org>
> 
> Found by Coverity in Gnulib.
> 
> * posix/glob.c (__glob): Add scratch_buffer_free invocation, to match
> scratch_buffer_init invocation.
> 
> Reviewed-by: Collin Funk <collin.funk1@gmail.com>

Hi Collin,

Is there any other fixes we can import from gnulib? It has been some time
since I synced our shared files with gnulib.

> 
> -- 8< --
> 
> Bruno pushed this change to Gnulib, and the patch applied to the version
> in glibc. So I have committed it under his name.
> 
> ---
>  posix/glob.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/posix/glob.c b/posix/glob.c
> index 0c86d26972..846528e252 100644
> --- a/posix/glob.c
> +++ b/posix/glob.c
> @@ -886,6 +886,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
>                    {
>                      /* We have to regard it as an error if we cannot find the
>                         home directory.  */
> +                    scratch_buffer_free (&pwtmpbuf);
>                      retval = GLOB_NOMATCH;
>                      goto out;
>                    }



More information about the Libc-alpha mailing list