Thread (35 messages) 35 messages, 3 authors, 2016-06-15
STALE3676d
Revisions (4)
  1. v1 current
  2. v2 [diff vs current]
  3. v3 [diff vs current]
  4. v4 [diff vs current]

[PATCH 1/5] dir.c: clean the entire struct in clear_exclude_list()

From: Nguyễn Thái Ngọc Duy <hidden>
Date: 2016-06-15 23:07:21
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 dir.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/dir.c b/dir.c
index d2a8f06..b8b4576 100644
--- a/dir.c
+++ b/dir.c
@@ -564,9 +564,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)
-- 
2.2.0.513.g477eb31
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help