]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_musiconhold.c: Fix format ref leak when parsing MOH config class. 87/4787/1
authorRichard Mudgett <rmudgett@digium.com>
Tue, 10 Jan 2017 18:30:57 +0000 (12:30 -0600)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 24 Jan 2017 19:55:12 +0000 (13:55 -0600)
Change-Id: Ica8e8e2ce7604c2c61ec55bef07dc675361d2ea5

res/res_musiconhold.c

index 3c7199ef4594bdf6b5194e7acf6244d7ae512f98..3bae1727e209492e173a5c0cc094892ca1f5de1c 100644 (file)
@@ -1060,13 +1060,14 @@ static void moh_parse_options(struct ast_variable *var, struct mohclass *mohclas
                                ast_set_flag(mohclass, MOH_RANDSTART);
                        }
                } else if (!strcasecmp(var->name, "format")) {
+                       ao2_cleanup(mohclass->format);
                        mohclass->format = ast_format_cache_get(var->value);
                        if (!mohclass->format) {
                                ast_log(LOG_WARNING, "Unknown format '%s' -- defaulting to SLIN\n", var->value);
                                mohclass->format = ao2_bump(ast_format_slin);
                        }
-               }
-       }
+               }
+       }
 }
 
 static int moh_add_file(struct mohclass *class, const char *filepath)