From 41b40ddf18053a8d0909cc174f1cb7f5b02d56d1 Mon Sep 17 00:00:00 2001 From: berat Date: Sat, 23 Sep 2017 19:50:52 +0200 Subject: memory leak fixed --- example/ndpiReader.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'example') diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 218f251c3..822bce3a1 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -945,20 +945,12 @@ int updateIpTree(const char *key, addr_node **vrootp, const char *proto) { /* *********************************************** */ void freeIpTree(addr_node *root) { - while (root != NULL) { - addr_node *left = root->left; - - if(left == NULL) { - addr_node *right = root->right; - root->right = NULL; - root = right; - } else { - /* Rotate the left child up.*/ - root->left = left->right; - left->right = root; - root = left; - } - } + if (root != NULL){ + freeIpTree(root->left); + freeIpTree(root->right); + free(root); + root = NULL; + } } /* *********************************************** */ @@ -1077,7 +1069,6 @@ static void deletePortsStats(struct port_stats *stats) { HASH_ITER(hh, stats, current_port, tmp) { HASH_DEL(stats, current_port); freeIpTree(current_port->addr_tree); - free(current_port->addr_tree); free(current_port); } } -- cgit v1.2.3