diff --git a/lib/trie/dtrie.c b/lib/trie/dtrie.c index 28838298424..f0b26554930 100644 --- a/lib/trie/dtrie.c +++ b/lib/trie/dtrie.c @@ -76,7 +76,9 @@ void dtrie_delete(struct dtrie_node_t *root, struct dtrie_node_t *node, dt_delete_func_t delete_payload, const unsigned int branches) { unsigned int i; - if (node==NULL) return; + + if (node == NULL) return; + if (root == NULL) return; for (i=0; ichild[i], delete_payload, branches); @@ -123,6 +125,10 @@ int dtrie_insert(struct dtrie_node_t *root, const char *number, const unsigned i struct dtrie_node_t *node = root; unsigned char digit, i=0; + if (node == NULL) return -1; + if (root == NULL) return -1; + if (number == NULL) return -1; + while (ichild[i]) { sum += dtrie_leaves(root->child[i], branches); @@ -220,6 +228,10 @@ void **dtrie_longest_match(struct dtrie_node_t *root, const char *number, unsigned char digit, i = 0; void **ret = NULL; + if (node == NULL) return NULL; + if (root == NULL) return NULL; + if (number == NULL) return NULL; + if (nmatchptr) *nmatchptr=-1; if (node->data != NULL) { if (nmatchptr) *nmatchptr=0;