X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Futils_ignorelist.c;h=532eb4b0029837318cf60a2adbecf901a2590b3a;hb=c8e76316f549f75149d4787fd2e2390bbaee5531;hp=31a3e665fd8609df3aac6df99f567729f5c5bb65;hpb=9674512a648641868b28c0c29802ba9de92bbfe5;p=collectd.git diff --git a/src/utils_ignorelist.c b/src/utils_ignorelist.c index 31a3e665..532eb4b0 100644 --- a/src/utils_ignorelist.c +++ b/src/utils_ignorelist.c @@ -285,7 +285,6 @@ int ignorelist_add (ignorelist_t *il, const char *entry) { int ret; size_t entry_len; - char *entry_copy; if (il == NULL) { @@ -306,6 +305,8 @@ int ignorelist_add (ignorelist_t *il, const char *entry) /* regex string is enclosed in "/.../" */ if ((entry_len > 2) && (entry[0] == '/') && entry[entry_len - 1] == '/') { + char *entry_copy; + /* We need to copy `entry' since it's const */ entry_copy = smalloc (entry_len); memset (entry_copy, '\0', entry_len); @@ -333,10 +334,15 @@ int ignorelist_match (ignorelist_t *il, const char *entry) { ignorelist_item_t *traverse; + assert (il != NULL); + /* if no entries, collect all */ if (il->head == NULL) return (0); + if ((entry == NULL) || (strlen (entry) == 0)) + return (0); + /* traverse list and check entries */ for (traverse = il->head; traverse != NULL; traverse = traverse->next) {