Bruno Haible via Gnulib discussion list <[email protected]> writes: > 2025-10-21 Bruno Haible <[email protected]> > > glob: Fix a memory leak. > Found by Coverity. > * lib/glob.c (__glob): Add scratch_buffer_free invocation, to match > scratch_buffer_init invocation. > > diff --git a/lib/glob.c b/lib/glob.c > index 48f10ae0e1..dc21014aff 100644 > --- a/lib/glob.c > +++ b/lib/glob.c > @@ -872,6 +872,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; > }
Interesting. I'm suprised Coverity caught this. I would have assumed that it only works on standard functions like malloc/free. Or functions with __attributes__ used, which it doesn't like look these do. > Collin, feel free to port this fix to glibc. Your patch applied cleanly there since the files are pretty closely synced. So I just made some minor adjustments to the commit message and committed it under your name [1]. Thanks, Collin [1] https://forge.sourceware.org/glibc/glibc-mirror/commit/1eba0b35ad3e860a0d4fae12579e8399355eee44
