[sr-dev] git:kamailio_3.0: Fixed a memory leak on shm memory, caused by the dtrie implementation.

Marius Zbihlei marius.zbihlei at 1and1.ro
Wed Jul 7 11:50:16 CEST 2010


Module: sip-router
Branch: kamailio_3.0
Commit: 5c5cc3df5301e86ee78d79f52aa917e0f67f37e8
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5c5cc3df5301e86ee78d79f52aa917e0f67f37e8

Author: Marius Zbihlei <marius.zbihlei at 1and1.ro>
Committer: Marius Zbihlei <marius.zbihlei at 1and1.ro>
Date:   Wed Jul  7 12:39:58 2010 +0300

Fixed a memory leak on shm memory, caused by the dtrie implementation.

 dtrie_destroy and dtrie_clear could leak 10 * sizeof(void*) for each node in the trie.
Mainly affected carrierroute and userblacklist modules

---

 lib/trie/dtrie.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/lib/trie/dtrie.c b/lib/trie/dtrie.c
index 531340b..9965263 100644
--- a/lib/trie/dtrie.c
+++ b/lib/trie/dtrie.c
@@ -88,10 +88,13 @@ void dtrie_delete(struct dtrie_node_t *root, struct dtrie_node_t *node,
 	if (delete_payload) {
 		delete_payload(node->data);
 	}
+
 	node->data = NULL;
-	
+
 	if (node != root) {
 		LM_DBG("free node at %p\n", node);
+		shm_free(node->child);
+		node->child = NULL;
 		shm_free(node);
 	}
 }
@@ -102,6 +105,7 @@ void dtrie_destroy(struct dtrie_node_t **root, dt_delete_func_t delete_payload,
 	if ((root!=NULL) && (*root!=NULL)) {
 		dtrie_delete(*root, *root, delete_payload, branches);
 		LM_DBG("free root at %p\n", root);
+		shm_free((*root)->child);
 		shm_free(*root);
 		*root = NULL;
 	}




More information about the sr-dev mailing list