diff --git a/main/audiohook.c b/main/audiohook.c index 8156d0ff37721983a9cb8eb89e009fbb1e3e893a..640ec2f5aa252743b9e73f062673585c635b8398 100644 --- a/main/audiohook.c +++ b/main/audiohook.c @@ -441,12 +441,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