dir.c: clean the entire struct in clear_exclude_list()
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sun, 27 Dec 2015 01:54:34 +0000 (08:54 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 28 Dec 2015 20:48:27 +0000 (12:48 -0800)
Make sure "el" can be reuseable again. The problem was el->alloc is
not cleared and may cause segfaults next time because add_exclude()
thinks el->excludes (being NULL) has enough space. Just clear the
entire struct to be safe.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dir.c
diff --git a/dir.c b/dir.c
index 3f7a0256b61552c6c3f80f710bd042b697d79da9..736ff2ac1127a5578c5dc2e915b3e1cf5b203bfb 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -501,9 +501,7 @@ void clear_exclude_list(struct exclude_list *el)
        free(el->excludes);
        free(el->filebuf);
 
-       el->nr = 0;
-       el->excludes = NULL;
-       el->filebuf = NULL;
+       memset(el, 0, sizeof(*el));
 }
 
 static void trim_trailing_spaces(char *buf)