diff --git a/tpws/ipset.c b/tpws/ipset.c index 266cc3c..b803205 100644 --- a/tpws/ipset.c +++ b/tpws/ipset.c @@ -242,12 +242,22 @@ bool IpsetCheck(const struct desync_profile *dp, const struct in_addr *ipv4, con static struct ipset_file *RegisterIpset_(struct ipset_files_head *ipsets, struct ipset_collection_head *ips_collection, const char *filename) { struct ipset_file *hfile; - if (!(hfile=ipset_files_search(ipsets, filename))) - if (!(hfile=ipset_files_add(ipsets, filename))) + if (filename) + { + if (!(hfile=ipset_files_search(ipsets, filename))) + if (!(hfile=ipset_files_add(ipsets, filename))) + return NULL; + if (!ipset_collection_search(ips_collection, filename)) + if (!ipset_collection_add(ips_collection, hfile)) + return NULL; + } + else + { + if (!(hfile=ipset_files_add(ipsets, NULL))) return NULL; - if (!ipset_collection_search(ips_collection, filename)) if (!ipset_collection_add(ips_collection, hfile)) return NULL; + } return hfile; } struct ipset_file *RegisterIpset(struct desync_profile *dp, bool bExclude, const char *filename) diff --git a/tpws/pools.c b/tpws/pools.c index 052e3b3..8e8c710 100644 --- a/tpws/pools.c +++ b/tpws/pools.c @@ -154,18 +154,22 @@ void strlist_destroy(struct str_list_head *head) - struct hostlist_file *hostlist_files_add(struct hostlist_files_head *head, const char *filename) { struct hostlist_file *entry = malloc(sizeof(struct hostlist_file)); if (entry) { - if (filename && !(entry->filename = strdup(filename))) + if (filename) { - free(entry); - return false; + if (!(entry->filename = strdup(filename))) + { + free(entry); + return false; + } } - entry->mod_time=0; + else + entry->filename = NULL; + entry->mod_time = 0; entry->hostlist = NULL; LIST_INSERT_HEAD(head, entry, next); } @@ -369,12 +373,17 @@ struct ipset_file *ipset_files_add(struct ipset_files_head *head, const char *fi struct ipset_file *entry = malloc(sizeof(struct ipset_file)); if (entry) { - if (filename && !(entry->filename = strdup(filename))) + if (filename) { - free(entry); - return false; + if (!(entry->filename = strdup(filename))) + { + free(entry); + return false; + } } - entry->mod_time=0; + else + entry->filename = NULL; + entry->mod_time = 0; memset(&entry->ipset,0,sizeof(entry->ipset)); LIST_INSERT_HEAD(head, entry, next); }