diff options
author | emanuele-f <black.silver@hotmail.it> | 2019-10-08 11:07:59 +0200 |
---|---|---|
committer | emanuele-f <black.silver@hotmail.it> | 2019-10-08 11:07:59 +0200 |
commit | e939f1c1d1bfa744d430e64305010bf918c5dfbe (patch) | |
tree | 2943063cf72d7560674acbc0093e54010343a657 /src | |
parent | b2c8cb655c8d70dafe67bad8da8099a4e8c6a517 (diff) |
Fix leaks in ndpi_load_hostname_category when ac_automata_add fails
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/ndpi_main.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index f3a23d90c..c5f2f6995 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -4285,29 +4285,31 @@ int ndpi_load_hostname_category(struct ndpi_detection_module_struct *ndpi_str, if(h) { h->expression = name, h->id = (unsigned int)category; - if(h->expression == NULL) { - ndpi_free(h); - return(-2); - } - h->next = ndpi_str->custom_categories.to_load; ndpi_str->custom_categories.to_load = h; ndpi_str->custom_categories.num_to_load++; - } else - return(-1); + } else { + free(name); + return(-1); + } } #else AC_PATTERN_t ac_pattern; memset(&ac_pattern, 0, sizeof(ac_pattern)); - if(ndpi_str->custom_categories.hostnames_shadow.ac_automa == NULL) + if(ndpi_str->custom_categories.hostnames_shadow.ac_automa == NULL) { + free(name); return(-1); + } ac_pattern.astring = name, ac_pattern.length = strlen(ac_pattern.astring); ac_pattern.rep.number = (int)category; - ac_automata_add(ndpi_str->custom_categories.hostnames_shadow.ac_automa, &ac_pattern); + if(ac_automata_add(ndpi_str->custom_categories.hostnames_shadow.ac_automa, &ac_pattern) != ACERR_SUCCESS) { + free(name); + return(-1); + } #endif return(0); |