]> Savannah Git Hosting - gnulib.git/commitdiff
glob: Fix more memory leaks.
authorBruno Haible <bruno@clisp.org>
Thu, 6 Jul 2017 21:21:49 +0000 (23:21 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 6 Jul 2017 21:23:21 +0000 (23:23 +0200)
* lib/glob.c (glob): Free dirname before returning.
Reported by Coverity and Tim Rühsen.

ChangeLog
lib/glob.c

index 1492d791cc96c71f8e2e281af0c1888366d68876..78191f8a5cc17e4966c6a6fa0accb39424581810 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-07-06  Bruno Haible  <bruno@clisp.org>
+
+       glob: Fix more memory leaks.
+       * lib/glob.c (glob): Free dirname before returning.
+       Reported by Coverity and Tim Rühsen.
+
 2017-07-06  Paul Eggert  <eggert@cs.ucla.edu>
 
        parse-datetime: fix uninit var bug
index dc0aff693e1f96204bb2102b428c42332b7686cd..a38cf229b08d2b708907aed46dd3dc5020334561 100644 (file)
@@ -1091,6 +1091,8 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
               p = mempcpy (pglob->gl_pathv[newcount], dirname, dirlen);
               p[0] = '/';
               p[1] = '\0';
+              if (__glibc_unlikely (malloc_dirname))
+                free (dirname);
             }
           else
             {