]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix crash when moving audiohooks between channels.
authorJoshua Colp <jcolp@digium.com>
Tue, 31 Mar 2009 14:06:39 +0000 (14:06 +0000)
committerJoshua Colp <jcolp@digium.com>
Tue, 31 Mar 2009 14:06:39 +0000 (14:06 +0000)
Handle the scenario where we are called to move audiohooks between channels
and the source channel does not actually have any on it.

(closes issue #14734)
Reported by: corruptor

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

main/audiohook.c

index cd5b7ca8a83a3c55198cfee92a232f886e25d6f0..fdd241db2ce950089edfd156eea5d4e3c99b8dae 100644 (file)
@@ -453,12 +453,12 @@ static struct ast_audiohook *find_audiohook_by_source(struct ast_audiohook_list
 
 void ast_audiohook_move_by_source (struct ast_channel *old_chan, struct ast_channel *new_chan, const char *source)
 {
-       struct ast_audiohook *audiohook = find_audiohook_by_source(old_chan->audiohooks, source);
+       struct ast_audiohook *audiohook;
 
-       if (!audiohook) {
+       if (!old_chan->audiohooks || !(audiohook = find_audiohook_by_source(old_chan->audiohooks, source))) {
                return;
        }
-       
+
        /* By locking both channels and the audiohook, we can assure that
         * another thread will not have a chance to read the audiohook's status
         * as done, even though ast_audiohook_remove signals the trigger