From 3e0b580f1a91264b3f9c761a92c31873417894be Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 26 Sep 2018 12:47:54 +0200 Subject: [PATCH] Don't return -1 as number of read whitelist domains if there is no whitelist file. Also, don't try to free the array of whitelist domains if there are none. Signed-off-by: DL6ER --- regex.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/regex.c b/regex.c index c29855830..2b6224ebb 100644 --- a/regex.c +++ b/regex.c @@ -69,8 +69,12 @@ static void free_whitelist_domains(void) whitelist.count = 0; - free(whitelist.domains); - whitelist.domains = NULL; + // Free whitelist domains array only allocated + if(whitelist.domains != NULL) + { + free(whitelist.domains); + whitelist.domains = NULL; + } } bool match_regex(char *input) @@ -297,5 +301,5 @@ void read_regex_from_file(void) // Read whitelisted domains from file read_whitelist_from_file(); - logg("Compiled %i Regex filters and %i whitelisted domains in %.1f msec (%i errors)", (num_regex-skipped), whitelist.count, timer_elapsed_msec(REGEX_TIMER), errors); + logg("Compiled %i Regex filters and %i whitelisted domains in %.1f msec (%i errors)", (num_regex-skipped), whitelist.count > 0 ? whitelist.count : 0, timer_elapsed_msec(REGEX_TIMER), errors); }