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

Collin Funk collin.funk1@gmail.com
Wed Oct 22 02:52:22 GMT 2025


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>

-- 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;
                   }
-- 
2.51.0



More information about the Libc-alpha mailing list