summaryrefslogtreecommitdiffstats
path: root/src/simple_pattern.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/simple_pattern.c')
-rw-r--r--src/simple_pattern.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/simple_pattern.c b/src/simple_pattern.c
index 7e4424297..f72a42d06 100644
--- a/src/simple_pattern.c
+++ b/src/simple_pattern.c
@@ -169,7 +169,7 @@ static inline int match_pattern(struct simple_pattern *m, const char *str, size_
int simple_pattern_matches(SIMPLE_PATTERN *list, const char *str) {
struct simple_pattern *m, *root = (struct simple_pattern *)list;
- if(unlikely(!root)) return 0;
+ if(unlikely(!root || !str || !*str)) return 0;
size_t len = strlen(str);
for(m = root; m ; m = m->next)
@@ -184,8 +184,8 @@ int simple_pattern_matches(SIMPLE_PATTERN *list, const char *str) {
static inline void free_pattern(struct simple_pattern *m) {
if(!m) return;
- if(m->next) free_pattern(m->next);
- if(m->child) free_pattern(m->child);
+ free_pattern(m->child);
+ free_pattern(m->next);
freez((void *)m->match);
freez(m);
}
@@ -193,5 +193,5 @@ static inline void free_pattern(struct simple_pattern *m) {
void simple_pattern_free(SIMPLE_PATTERN *list) {
if(!list) return;
- free_pattern(((struct simple_pattern *)list)->next);
+ free_pattern(((struct simple_pattern *)list));
}