From 7fa60281bf3c261fe527d36492869892a6836aed Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sat, 4 Aug 2007 19:09:21 +0000 Subject: [PATCH] Avoid a crash if pop_local_filters() has some pointer gaps. --- exclude.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/exclude.c b/exclude.c index 1a0be70f..96469ab3 100644 --- a/exclude.c +++ b/exclude.c @@ -494,25 +494,29 @@ void pop_local_filters(void *mem) void change_local_filter_dir(const char *dname, int dlen, int dir_depth) { - static int min_depth = MAXPATHLEN, cur_depth = -1; + static int cur_depth = -1; static void *filt_array[MAXPATHLEN/2+1]; if (!dname) { - while (cur_depth >= min_depth) - pop_local_filters(filt_array[cur_depth--]); - min_depth = MAXPATHLEN; - cur_depth = -1; + for ( ; cur_depth >= 0; cur_depth--) { + if (filt_array[cur_depth]) { + pop_local_filters(filt_array[cur_depth]); + filt_array[cur_depth] = NULL; + } + } return; } assert(dir_depth < MAXPATHLEN/2+1); - while (cur_depth >= dir_depth && cur_depth >= min_depth) - pop_local_filters(filt_array[cur_depth--]); - cur_depth = dir_depth; - if (cur_depth < min_depth) - min_depth = cur_depth; + for ( ; cur_depth >= dir_depth; cur_depth--) { + if (filt_array[cur_depth]) { + pop_local_filters(filt_array[cur_depth]); + filt_array[cur_depth] = NULL; + } + } + cur_depth = dir_depth; filt_array[cur_depth] = push_local_filters(dname, dlen); } -- 2.34.1