Skip to content

Commit

Permalink
dir.c: clean the entire struct in clear_exclude_list()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Dec 28, 2015
1 parent 441c4a4 commit 2653a8c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2653a8c

Please sign in to comment.