diff options
author | qwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-03-14 14:32:55 +0000 |
---|---|---|
committer | qwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-03-14 14:32:55 +0000 |
commit | e63d774e7f0ebf1a4a4d6e6f866840898312d1d2 (patch) | |
tree | fe390119acb33bef3aad7be3908fdb85db39a82f /res/res_musiconhold.c | |
parent | d7f3722fa52e85852e4959d32dfc48c7e82099bc (diff) |
Merged revisions 108682 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r108682 | qwell | 2008-03-14 09:29:05 -0500 (Fri, 14 Mar 2008) | 4 lines
Fix a potential segfault if chan (or chan->music_state) is NULL.
Closes issue #12210, credit to edantie for pointing this out.
........
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@108683 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r-- | res/res_musiconhold.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index b43a51d60..70f846976 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -210,22 +210,25 @@ static void ast_moh_free_class(struct mohclass **mohclass) static void moh_files_release(struct ast_channel *chan, void *data) { - struct moh_files_state *state = chan->music_state; + struct moh_files_state *state; - if (chan && state) { - if (chan->stream) { - ast_closestream(chan->stream); - chan->stream = NULL; - } - ast_verb(3, "Stopped music on hold on %s\n", chan->name); + if (chan) { + if ((state = chan->music_state)) { + if (chan->stream) { + ast_closestream(chan->stream); + chan->stream = NULL; + } + ast_verb(3, "Stopped music on hold on %s\n", chan->name); + + if (state->origwfmt && ast_set_write_format(chan, state->origwfmt)) { + ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%d'\n", chan->name, state->origwfmt); + } + state->save_pos = state->pos; - if (state->origwfmt && ast_set_write_format(chan, state->origwfmt)) { - ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%d'\n", chan->name, state->origwfmt); + if (ast_atomic_dec_and_test(&state->class->inuse) && state->class->delete) + ast_moh_destroy_one(state->class); } - state->save_pos = state->pos; } - if (ast_atomic_dec_and_test(&state->class->inuse) && state->class->delete) - ast_moh_destroy_one(state->class); } |