aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorseanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b>2010-12-15 21:28:29 +0000
committerseanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b>2010-12-15 21:28:29 +0000
commitad95d394ecfa01a3877731a348dfd23815ff77fc (patch)
tree9a9422610cc86f8b2bc6e440f44eba952e4ed146
parentf116a82f97099be52e3c166eebb87d34ea4287eb (diff)
Fix reference and container leaks when running 'astobj2 test.'
We need to make sure that ao2_iterator_destroy is called once for each time that ao2_iterator_init is called. Also make sure to unref a newly allocated object that we've linked into a container. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@298345 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--main/astobj2.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/main/astobj2.c b/main/astobj2.c
index 12da832d6..9a78a4c17 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -789,6 +789,7 @@ static int handle_astobj2_test(int fd, int argc, char *argv[])
ast_cli(fd, "object %d allocated as %p\n", i, obj);
sprintf(obj, "-- this is obj %d --", i);
ao2_link(c1, obj);
+ ao2_ref(obj, -1);
}
ast_cli(fd, "testing callbacks\n");
ao2_callback(c1, 0, print_cb, &fd);
@@ -805,12 +806,14 @@ static int handle_astobj2_test(int fd, int argc, char *argv[])
ao2_unlink(c1, obj);
ao2_ref(obj, -1);
}
+ ao2_iterator_destroy(&ai);
ast_cli(fd, "testing iterators again\n");
ai = ao2_iterator_init(c1, 0);
while ( (obj = ao2_iterator_next(&ai)) ) {
ast_cli(fd, "iterator on <%s>\n", obj);
ao2_ref(obj, -1);
}
+ ao2_iterator_destroy(&ai);
}
ast_cli(fd, "testing callbacks again\n");
ao2_callback(c1, 0, print_cb, &fd);