summaryrefslogtreecommitdiff
path: root/res/res_musiconhold.c
diff options
context:
space:
mode:
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r--res/res_musiconhold.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 3c61b26fe..057c41326 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -1828,7 +1828,11 @@ static int load_moh_classes(int reload)
static void ast_moh_destroy(void)
{
ast_verb(2, "Destroying musiconhold processes\n");
- ao2_t_callback(mohclasses, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, NULL, NULL, "Destroy callback");
+ if (mohclasses) {
+ ao2_t_callback(mohclasses, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, NULL, NULL, "Destroy callback");
+ ao2_ref(mohclasses, -1);
+ mohclasses = NULL;
+ }
}
static char *handle_cli_moh_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)