summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2012-01-27 18:47:16 +0000
committerRichard Mudgett <rmudgett@digium.com>2012-01-27 18:47:16 +0000
commit27b69e7d29dc100e5fdf3cf911c3a02f3b5fd2b5 (patch)
tree7ad1cbac33a65eb9773db40058cabff69fe2eef1 /channels
parent5bfea5fdbfca835b29e14ec9a28345c6095431b5 (diff)
Audit of ao2_iterator_init() usage for v1.8.
Fixes numerous reference leaks and missing ao2_iterator_destroy() calls as a result. Review: https://reviewboard.asterisk.org/r/1697/ ........ Merged revisions 352955 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 352956 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@352957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_iax2.c16
-rw-r--r--channels/chan_sip.c10
2 files changed, 15 insertions, 11 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 2255801c0..9d442d5a0 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -2636,6 +2636,7 @@ static char *handle_cli_iax2_show_callno_limits(struct ast_cli_entry *e, int cmd
sin.sin_addr.s_addr = peercnt->addr;
if (a->argc == 5 && (!strcasecmp(a->argv[4], ast_inet_ntoa(sin.sin_addr)))) {
ast_cli(a->fd, "%-15s %-12d %-12d\n", ast_inet_ntoa(sin.sin_addr), peercnt->cur, peercnt->limit);
+ ao2_ref(peercnt, -1);
found = 1;
break;
} else {
@@ -6680,8 +6681,7 @@ static char *handle_cli_iax2_show_users(struct ast_cli_entry *e, int cmd, struct
ast_cli(a->fd, FORMAT, "Username", "Secret", "Authen", "Def.Context", "A/C","Codec Pref");
i = ao2_iterator_init(users, 0);
- for (user = ao2_iterator_next(&i); user;
- user_unref(user), user = ao2_iterator_next(&i)) {
+ for (; (user = ao2_iterator_next(&i)); user_unref(user)) {
if (havepattern && regexec(&regexbuf, user->name, 0, NULL, 0))
continue;
@@ -6769,8 +6769,7 @@ static int __iax2_show_peers(int fd, int *total, struct mansession *s, const int
ast_cli(fd, FORMAT2, "Name/Username", "Host", " ", "Mask", "Port", " ", "Status", "Description");
i = ao2_iterator_init(peers, 0);
- for (peer = ao2_iterator_next(&i); peer;
- peer_unref(peer), peer = ao2_iterator_next(&i)) {
+ for (; (peer = ao2_iterator_next(&i)); peer_unref(peer)) {
char nm[20];
char status[20];
int retstatus;
@@ -7093,7 +7092,7 @@ static int manager_iax2_show_peer_list(struct mansession *s, const struct messag
i = ao2_iterator_init(peers, 0);
- for (peer = ao2_iterator_next(&i); peer; peer_unref(peer), peer = ao2_iterator_next(&i)) {
+ for (; (peer = ao2_iterator_next(&i)); peer_unref(peer)) {
encmethods_to_str(peer->encmethods, encmethods);
astman_append(s, "Event: PeerEntry\r\n%sChanneltype: IAX\r\n", idtext);
if (!ast_strlen_zero(peer->username)) {
@@ -7676,8 +7675,8 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
return res;
}
/* Search the userlist for a compatible entry, and fill in the rest */
- i = ao2_iterator_init(users, 0);
ast_sockaddr_from_sin(&addr, sin);
+ i = ao2_iterator_init(users, 0);
while ((user = ao2_iterator_next(&i))) {
if ((ast_strlen_zero(iaxs[callno]->username) || /* No username specified */
!strcmp(iaxs[callno]->username, user->name)) /* Or this username specified */
@@ -14681,10 +14680,9 @@ static int users_data_provider_get(const struct ast_data_search *search,
char *pstr = "";
i = ao2_iterator_init(users, 0);
- while ((user = ao2_iterator_next(&i))) {
+ for (; (user = ao2_iterator_next(&i)); user_unref(user)) {
data_user = ast_data_add_node(data_root, "user");
if (!data_user) {
- user_unref(user);
continue;
}
@@ -14733,8 +14731,6 @@ static int users_data_provider_get(const struct ast_data_search *search,
}
ast_data_add_str(data_user, "codec-preferences", pstr);
- user_unref(user);
-
if (!ast_data_search_match(search, data_user)) {
ast_data_remove_node(data_root, data_user);
}
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index a5634fe94..73a4b7400 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -17639,8 +17639,8 @@ static char *sip_prune_realtime(struct ast_cli_entry *e, int cmd, struct ast_cli
while ((pi = ao2_t_iterator_next(&i, "iterate thru peers table"))) {
ao2_lock(pi);
if (name && regexec(&regexbuf, pi->name, 0, NULL, 0)) {
- sip_unref_peer(pi, "toss iterator peer ptr before continue");
ao2_unlock(pi);
+ sip_unref_peer(pi, "toss iterator peer ptr before continue");
continue;
};
if (ast_test_flag(&pi->flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
@@ -31103,6 +31103,8 @@ static int peers_data_provider_get(const struct ast_data_search *search,
/* transfer mode */
enum_node = ast_data_add_node(data_peer, "allowtransfer");
if (!enum_node) {
+ ao2_unlock(peer);
+ ao2_ref(peer, -1);
continue;
}
ast_data_add_str(enum_node, "text", transfermode2str(peer->allowtransfer));
@@ -31142,6 +31144,8 @@ static int peers_data_provider_get(const struct ast_data_search *search,
/* amaflags */
enum_node = ast_data_add_node(data_peer, "amaflags");
if (!enum_node) {
+ ao2_unlock(peer);
+ ao2_ref(peer, -1);
continue;
}
ast_data_add_int(enum_node, "value", peer->amaflags);
@@ -31150,6 +31154,8 @@ static int peers_data_provider_get(const struct ast_data_search *search,
/* sip options */
data_sip_options = ast_data_add_node(data_peer, "sipoptions");
if (!data_sip_options) {
+ ao2_unlock(peer);
+ ao2_ref(peer, -1);
continue;
}
for (x = 0 ; x < ARRAY_LEN(sip_options); x++) {
@@ -31159,6 +31165,8 @@ static int peers_data_provider_get(const struct ast_data_search *search,
/* callingpres */
enum_node = ast_data_add_node(data_peer, "callingpres");
if (!enum_node) {
+ ao2_unlock(peer);
+ ao2_ref(peer, -1);
continue;
}
ast_data_add_int(enum_node, "value", peer->callingpres);