Author: rmudgett
Date: Mon Aug 25 11:45:40 2014
New Revision: 422038

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=422038
Log:
res_musiconhold.c: Release any format refs before memset().

* Clear the channel music_state pointer before destroying the music_state
object for safety.
........

Merged revisions 422037 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    trunk/   (props changed)
    trunk/res/res_musiconhold.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: trunk/res/res_musiconhold.c
URL: 
http://svnview.digium.com/svn/asterisk/trunk/res/res_musiconhold.c?view=diff&rev=422038&r1=422037&r2=422038
==============================================================================
--- trunk/res/res_musiconhold.c (original)
+++ trunk/res/res_musiconhold.c Mon Aug 25 11:45:40 2014
@@ -479,6 +479,8 @@
        /* Resume MOH from where we left off last time or start from scratch? */
        if (state->save_total != class->total_files || strcmp(state->name, 
class->name) != 0) {
                /* Start MOH from scratch. */
+               ao2_cleanup(state->origwfmt);
+               ao2_cleanup(state->mohwfmt);
                memset(state, 0, sizeof(*state));
                if (ast_test_flag(class, MOH_RANDOMIZE) && class->total_files) {
                        state->pos = ast_random() % class->total_files;
@@ -974,6 +976,8 @@
                        mohclass_unref(state->class, "Uh Oh. Restarting MOH 
with an active class");
                        ast_log(LOG_WARNING, "Uh Oh. Restarting MOH with an 
active class\n");
                }
+               ao2_cleanup(state->origwfmt);
+               ao2_cleanup(state->mohwfmt);
                memset(state, 0, sizeof(*state));
        }
 
@@ -1304,6 +1308,7 @@
        struct moh_files_state *state = ast_channel_music_state(chan);
 
        if (state) {
+               ast_channel_music_state_set(chan, NULL);
                if (state->class) {
                        /* This should never happen.  We likely just leaked 
some resource. */
                        state->class =
@@ -1312,8 +1317,7 @@
                }
                ao2_cleanup(state->origwfmt);
                ao2_cleanup(state->mohwfmt);
-               ast_free(ast_channel_music_state(chan));
-               ast_channel_music_state_set(chan, NULL);
+               ast_free(state);
                /* Only held a module reference if we had a music state */
                ast_module_unref(ast_module_info->self);
        }


-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

svn-commits mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/svn-commits

Reply via email to