[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.
This commit is contained in:
Willy Tarreau 2011-03-09 07:27:02 +01:00
parent 1e2a170cf8
commit dfd7fca26c

View File

@ -1008,8 +1008,11 @@ struct acl_keyword *find_acl_kw(const char *kw)
return NULL;
}
/* NB: does nothing if <pat> is NULL */
static void free_pattern(struct acl_pattern *pat)
{
if (!pat)
return;
if (pat->ptr.ptr) {
if (pat->freeptrbuf)