]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix a memory leak in astobj2 that was pointed out by seanbright. When a container
authorRussell Bryant <russell@russellbryant.com>
Tue, 17 Jun 2008 15:48:31 +0000 (15:48 +0000)
committerRussell Bryant <russell@russellbryant.com>
Tue, 17 Jun 2008 15:48:31 +0000 (15:48 +0000)
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/branches/1.4@123271 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/astobj2.c

index 7cbf70cce7addeebfb168cb78e657c34ecd43fd4..bcf34556e6e56144cf878e247cd60938b89ada90 100644 (file)
@@ -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