From 27b69e7d29dc100e5fdf3cf911c3a02f3b5fd2b5 Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Fri, 27 Jan 2012 18:47:16 +0000 Subject: 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 --- apps/app_chanspy.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'apps/app_chanspy.c') 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; } } -- cgit v1.2.3