[Asterisk-code-review] res musiconhold.c: Fix format ref leak when parsing MOH conf... (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Tue Jan 24 13:40:31 CST 2017


Richard Mudgett has uploaded a new change for review. ( https://gerrit.asterisk.org/4786 )

Change subject: res_musiconhold.c: Fix format ref leak when parsing MOH config class.
......................................................................

res_musiconhold.c: Fix format ref leak when parsing MOH config class.

Change-Id: Ica8e8e2ce7604c2c61ec55bef07dc675361d2ea5
---
M res/res_musiconhold.c
1 file changed, 2 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/86/4786/1

diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 6f51820..6b0f00a 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -1433,6 +1433,7 @@
 				else if (!strcasecmp(tmp->name, "sort") && !strcasecmp(tmp->value, "alpha")) 
 					ast_set_flag(mohclass, MOH_SORTALPHA);
 				else if (!strcasecmp(tmp->name, "format")) {
+					ao2_cleanup(mohclass->format);
 					mohclass->format = ast_format_cache_get(tmp->value);
 					if (!mohclass->format) {
 						ast_log(LOG_WARNING, "Unknown format '%s' -- defaulting to SLIN\n", tmp->value);
@@ -1765,6 +1766,7 @@
 			} else if (!strcasecmp(var->name, "sort") && !strcasecmp(var->value, "alpha")) {
 				ast_set_flag(class, MOH_SORTALPHA);
 			} else if (!strcasecmp(var->name, "format")) {
+				ao2_cleanup(class->format);
 				class->format = ast_format_cache_get(var->value);
 				if (!class->format) {
 					ast_log(LOG_WARNING, "Unknown format '%s' -- defaulting to SLIN\n", var->value);

-- 
To view, visit https://gerrit.asterisk.org/4786
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ica8e8e2ce7604c2c61ec55bef07dc675361d2ea5
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-code-review mailing list