diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-17 15:48:31 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-17 15:48:31 +0000 |
commit | bdd0922540d84ba739c482f763c5e6cc314fac2f (patch) | |
tree | be91722c00ab614d0b24cec2c01caabe57615fcc /main/astobj2.c | |
parent | f05679d13ececf9e78d26c16df6f62e622873666 (diff) |
Fix a memory leak in astobj2 that was pointed out by seanbright. When a container
got destroyed, the underlying bucket list entry for each object that was in the
container at that time did not get free'd.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@123271 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/astobj2.c')
-rw-r--r-- | main/astobj2.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/main/astobj2.c b/main/astobj2.c index 7cbf70cce..bcf34556e 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -599,9 +599,18 @@ static int cd_cb(void *obj, void *arg, int flag) static void container_destruct(void *_c) { struct ao2_container *c = _c; + int i; ao2_callback(c, OBJ_UNLINK, cd_cb, NULL); + for (i = 0; i < c->n_buckets; i++) { + struct bucket_list *cur; + + while ((cur = AST_LIST_REMOVE_HEAD(&c->buckets[i], entry))) { + ast_free(cur); + } + } + #ifdef AO2_DEBUG ast_atomic_fetchadd_int(&ao2.total_containers, -1); #endif |