From b1d7f3165ba1c7a44a29017eb80491094aa240ba Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 31 Mar 2017 22:43:35 +0200 Subject: [PATCH 3/3] glob: Fix invalid free() call. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 | 7 +++++++ lib/glob.c | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index cca7542..2e01161 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2017-03-31 Bruno Haible + 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 + glob: Fix memory leaks. * lib/glob.c (glob): Free allocated memory before returning. Reported by Coverity via Tim Rühsen. diff --git a/lib/glob.c b/lib/glob.c index 1337817..9305038 100644 --- a/lib/glob.c +++ b/lib/glob.c @@ -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 -- 2.7.4