tpws: fixed list fixes

This commit is contained in:
bol-van
2024-11-24 16:47:51 +03:00
parent 422faaa29c
commit f00b45a28e
2 changed files with 31 additions and 12 deletions

View File

@@ -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);
}