summaryrefslogtreecommitdiff
path: root/apps/app_chanspy.c
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 /apps/app_chanspy.c
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 'apps/app_chanspy.c')
-rw-r--r--apps/app_chanspy.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 54e473681..4c709cfcc 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -828,11 +828,13 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
}
if (!iter) {
- return -1;
+ res = -1;
+ goto exit;
}
res = ast_waitfordigit(chan, waitms);
if (res < 0) {
+ iter = ast_channel_iterator_destroy(iter);
ast_clear_flag(chan, AST_FLAG_SPYING);
break;
}
@@ -840,10 +842,12 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
char tmp[2];
tmp[0] = res;
tmp[1] = '\0';
- if (!ast_goto_if_exists(chan, exitcontext, tmp, 1))
+ if (!ast_goto_if_exists(chan, exitcontext, tmp, 1)) {
+ iter = ast_channel_iterator_destroy(iter);
goto exit;
- else
+ } else {
ast_debug(2, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
+ }
}
/* reset for the next loop around, unless overridden later */
@@ -982,10 +986,12 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
if (res == -1) {
ast_autochan_destroy(autochan);
+ iter = ast_channel_iterator_destroy(iter);
goto exit;
} else if (res == -2) {
res = 0;
ast_autochan_destroy(autochan);
+ iter = ast_channel_iterator_destroy(iter);
goto exit;
} else if (res > 1 && spec) {
struct ast_channel *next;
@@ -1005,6 +1011,7 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
}
}
} else if (res == 0 && ast_test_flag(flags, OPTION_EXITONHANGUP)) {
+ iter = ast_channel_iterator_destroy(iter);
goto exit;
}
}