]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_musiconhold.c: Ensure we're always locked around music state access.
authorSean Bright <sean@seanbright.com>
Tue, 8 Apr 2025 19:54:37 +0000 (15:54 -0400)
committergithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Fri, 27 Jun 2025 14:01:24 +0000 (14:01 +0000)
res/res_musiconhold.c

index 954c25335c8f1de49aa62b95ef0735155d266ee4..b53c7e29ae97dcbe0b2dfbc618c1c6c296170f3b 100644 (file)
@@ -1544,8 +1544,10 @@ static int _moh_unregister(struct mohclass *moh, const char *file, int line, con
  */
 static void local_ast_moh_cleanup(struct ast_channel *chan)
 {
-       struct moh_files_state *state = ast_channel_music_state(chan);
+       struct moh_files_state *state;
 
+       ast_channel_lock(chan);
+       state = ast_channel_music_state(chan);
        if (state) {
                ast_channel_music_state_set(chan, NULL);
                if (state->class) {
@@ -1560,6 +1562,7 @@ static void local_ast_moh_cleanup(struct ast_channel *chan)
                /* Only held a module reference if we had a music state */
                ast_module_unref(ast_module_info->self);
        }
+       ast_channel_unlock(chan);
 }
 
 /*! \brief Support routing for 'moh unregister class' CLI