aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
Diffstat (limited to 'res')
-rw-r--r--res/res_musiconhold.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 8af2b76b8..e530744cd 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -1347,7 +1347,10 @@ static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, con
* has a pointer to a freed mohclass, so any operations involving the mohclass container would result in reading
* invalid memory.
*/
- moh_register(mohclass, 0, DONT_UNREF);
+ if (moh_register(mohclass, 0, DONT_UNREF) == -1) {
+ mohclass = mohclass_unref(mohclass, "unreffing mohclass failed to register");
+ return -1;
+ }
} else {
/* We don't register RT moh class, so let's init it manualy */