dir.c: clean the entire struct in clear_exclude_list()
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>
Nguyễn Thái Ngọc Duy committed
Dec 27, 2015 at 08:54 UTC
2653a8c6fa0466828061a3132421cf13a5d6d924
1 file changed
+1
-3
dir.c
+1
-3
@@ -501,9 +501,7 @@ void clear_exclude_list(struct exclude_list *el)
501
free(el->excludes);
502
free(el->filebuf);
503
504
- el->nr = 0;
505
- el->excludes = NULL;
506
- el->filebuf = NULL;
504
+ memset(el, 0, sizeof(*el));
505
}
506
507
static void trim_trailing_spaces(char *buf)