diff options
author | Russell Bryant <russell@russellbryant.com> | 2008-06-17 15:52:13 +0000 |
---|---|---|
committer | Russell Bryant <russell@russellbryant.com> | 2008-06-17 15:52:13 +0000 |
commit | 8b1646163d5deec0d63fe7a4807c239c14d03d61 (patch) | |
tree | d440998a243392fe1fd656558426407dd2488be9 /main | |
parent | c837af5e28b70c5030cfe1edd14a2be1b2700ffc (diff) |
Merged revisions 123271 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r123271 | russell | 2008-06-17 10:48:31 -0500 (Tue, 17 Jun 2008) | 4 lines
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: https://origsvn.digium.com/svn/asterisk/trunk@123272 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-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 007f12545..0bba65f17 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -808,9 +808,18 @@ static int cd_cb_debug(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 |