]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
app_chanspy, channel: fix frame leaks
authorKevin Harwell <kharwell@digium.com>
Thu, 26 Feb 2015 17:06:01 +0000 (17:06 +0000)
committerKevin Harwell <kharwell@digium.com>
Thu, 26 Feb 2015 17:06:01 +0000 (17:06 +0000)
Fixed a couple of frame leaks that were found during testing.

ASTERISK-24828 #close
Reported by: John Hardin
Review: https://reviewboard.asterisk.org/r/4445/

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@432362 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_chanspy.c
main/channel.c

index 37dd148f8d69696609cdf978cabdb7efaab761ba..31a1e18ca26f534db13c1efe1f81ff8dd7834614 100644 (file)
@@ -648,6 +648,9 @@ static int channel_spy(struct ast_channel *chan, struct ast_autochan *spyee_auto
        while (ast_waitfor(chan, -1) > -1 && csth.spy_audiohook.status == AST_AUDIOHOOK_STATUS_RUNNING) {
                if (!(f = ast_read(chan)) || ast_check_hangup(chan)) {
                        running = -1;
+                       if (f) {
+                               ast_frfree(f);
+                       }
                        break;
                }
 
index 8be8fe7a311f0f7e2462705bac76ebb94bc7e921..c89cd725e4b69a79e94a04e74d5f658823f4d86b 100644 (file)
@@ -3033,14 +3033,14 @@ int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer)
                                }
                        }
 
-                       if (res == 0) {
-                               ast_channel_lock(chan);
-                               while ((cur = AST_LIST_REMOVE_HEAD(&frames, frame_list))) {
+                       ast_channel_lock(chan);
+                       while ((cur = AST_LIST_REMOVE_HEAD(&frames, frame_list))) {
+                               if (res == 0) {
                                        ast_queue_frame_head(chan, cur);
-                                       ast_frfree(cur);
                                }
-                               ast_channel_unlock(chan);
+                               ast_frfree(cur);
                        }
+                       ast_channel_unlock(chan);
                } while (0);
                break;
        default: