Module: sip-router Branch: master Commit: 5146c47626d0fb9942ae914fc64c11bef728f5f0 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5146c476...
Author: Marius Zbihlei marius.zbihlei@1and1.ro Committer: Marius Zbihlei marius.zbihlei@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 (cherry picked from commit 5c5cc3df5301e86ee78d79f52aa917e0f67f37e8)
---
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; }