]> Savannah Git Hosting - gnulib.git/commitdiff
glob: Fix invalid free() call.
authorBruno Haible <bruno@clisp.org>
Fri, 31 Mar 2017 20:43:35 +0000 (22:43 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 31 Mar 2017 20:43:35 +0000 (22:43 +0200)
* lib/glob.c (glob): Reset malloc_home_dir when assigning a pointer to
static storage to home_dir.
Reported by Coverity via Tim Rühsen.

ChangeLog
lib/glob.c

index cca7542d45a5531313b6cb66cfffeb3a6060d89b..2e011615e4add2f32cb15a005655d9b5ca05e7d0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-03-31  Bruno Haible  <bruno@clisp.org>
+
+       glob: Fix invalid free() call.
+       * lib/glob.c (glob): Reset malloc_home_dir when assigning a pointer to
+       static storage to home_dir.
+       Reported by Coverity via Tim Rühsen.
+
 2017-03-31  Bruno Haible  <bruno@clisp.org>
 
        glob: Fix memory leaks.
index 1337817c2213e2c05a7de9113ea832e3eb395bbf..93050389cd3eda61647b23c2bbf65b5af03b464a 100644 (file)
@@ -809,7 +809,10 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
                   goto out;
                 }
               else
-                home_dir = (char *) "~"; /* No luck.  */
+                {
+                  home_dir = (char *) "~"; /* No luck.  */
+                  malloc_home_dir = 0;
+                }
             }
 #  endif /* WINDOWS32 */
 # endif