]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_musiconhold: Avoid spurious warning when 'format' is the empty string
authorSean Bright <sean.bright@gmail.com>
Tue, 11 Feb 2020 13:46:02 +0000 (08:46 -0500)
committerSean Bright <sean.bright@gmail.com>
Tue, 11 Feb 2020 13:51:10 +0000 (08:51 -0500)
The change to res_config_odbc that allowed empty strings to be
returned to realtime consumers¹ causes a warning to be emitted when
loading MoH classes. So we need to treat an empty 'format' as if it
was not specified to avoid the warning.

ASTERISK-28735 #close
Reported by: Ross Beer

[1] https://gerrit.asterisk.org/c/asterisk/+/13722

Change-Id: I9a271d721e1a0973e80ebe7d75b46a0d8fa0e5a5

res/res_musiconhold.c

index f029b16b08e937dd366cf3c0b4992f763c1734d9..60682fb6170c06d61c60c66d2fff961ab4a2a44c 100644 (file)
@@ -1517,7 +1517,7 @@ static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, con
                                        ast_set_flag(mohclass, MOH_RANDOMIZE);
                                else if (!strcasecmp(tmp->name, "sort") && !strcasecmp(tmp->value, "alpha"))
                                        ast_set_flag(mohclass, MOH_SORTALPHA);
-                               else if (!strcasecmp(tmp->name, "format")) {
+                               else if (!strcasecmp(tmp->name, "format") && !ast_strlen_zero(tmp->value)) {
                                        ao2_cleanup(mohclass->format);
                                        mohclass->format = ast_format_cache_get(tmp->value);
                                        if (!mohclass->format) {
@@ -1831,7 +1831,7 @@ static int load_moh_classes(int reload)
                                ast_set_flag(class, MOH_RANDOMIZE);
                        } else if (!strcasecmp(var->name, "sort") && !strcasecmp(var->value, "alpha")) {
                                ast_set_flag(class, MOH_SORTALPHA);
-                       } else if (!strcasecmp(var->name, "format")) {
+                       } else if (!strcasecmp(var->name, "format") && !ast_strlen_zero(var->value)) {
                                ao2_cleanup(class->format);
                                class->format = ast_format_cache_get(var->value);
                                if (!class->format) {