From dfd7fca26c6f0718ddc319433a4a0bc8f154a487 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 9 Mar 2011 07:27:02 +0100 Subject: [PATCH] [BUG] config: don't crash on empty pattern files. Both Hank A. Paulson and Rob at pixsense reported a crash when loading ACLs from a pattern file which contains empty lines. From the tests, it appears that only files that contain nothing but empty lines are causing that (in the past they would have had their line feeds loaded as patterns). The crash happens in the free_pattern() call which doesn't like to be called with a NULL pattern. Let's make it accept it so that it's more in line with the standard uses of free() which ignores NULLs. --- src/acl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/acl.c b/src/acl.c index fcfbf9fc2..26b82cb35 100644 --- a/src/acl.c +++ b/src/acl.c @@ -1008,8 +1008,11 @@ struct acl_keyword *find_acl_kw(const char *kw) return NULL; } +/* NB: does nothing if is NULL */ static void free_pattern(struct acl_pattern *pat) { + if (!pat) + return; if (pat->ptr.ptr) { if (pat->freeptrbuf)