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: https://origsvn.digium.com/svn/asterisk/branches/1.4@108682 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Jason Parker
2008-03-14 14:29:05 +00:00
parent efa3b46cdf
commit 503ca9f30c

View File

@@ -200,9 +200,10 @@ static void ast_moh_free_class(struct mohclass **mohclass)
static void moh_files_release(struct ast_channel *chan, void *data) 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) {
if ((state = chan->music_state)) {
if (chan->stream) { if (chan->stream) {
ast_closestream(chan->stream); ast_closestream(chan->stream);
chan->stream = NULL; chan->stream = NULL;
@@ -214,10 +215,12 @@ static void moh_files_release(struct ast_channel *chan, void *data)
ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%d'\n", chan->name, state->origwfmt); ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%d'\n", chan->name, state->origwfmt);
} }
state->save_pos = state->pos; state->save_pos = state->pos;
}
if (ast_atomic_dec_and_test(&state->class->inuse) && state->class->delete) if (ast_atomic_dec_and_test(&state->class->inuse) && state->class->delete)
ast_moh_destroy_one(state->class); ast_moh_destroy_one(state->class);
} }
}
}
static int ast_moh_files_next(struct ast_channel *chan) static int ast_moh_files_next(struct ast_channel *chan)