Skip to content

Commit 2653a8c

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 441c4a4 commit 2653a8c

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

dir.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,7 @@ void clear_exclude_list(struct exclude_list *el)
501501
free(el->excludes);
502502
free(el->filebuf);
503503

504-
el->nr = 0;
505-
el->excludes = NULL;
506-
el->filebuf = NULL;
504+
memset(el, 0, sizeof(*el));
507505
}
508506

509507
static void trim_trailing_spaces(char *buf)

0 commit comments

Comments
 (0)