]> 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:56:30 +0000 (07:56 -0600)
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 1bacb116a1fe5a4d827ef359bc24823e3bf5ecb3..dd9b8a5176135d37ac43d508ef5285c163866e00 100644 (file)
@@ -1119,7 +1119,7 @@ static void moh_parse_options(struct ast_variable *var, struct mohclass *mohclas
                        } else if (!strcasecmp(var->value, "randstart")) {
                                ast_set_flag(mohclass, MOH_RANDSTART);
                        }
-               } else if (!strcasecmp(var->name, "format")) {
+               } else if (!strcasecmp(var->name, "format") && !ast_strlen_zero(var->value)) {
                        ao2_cleanup(mohclass->format);
                        mohclass->format = ast_format_cache_get(var->value);
                        if (!mohclass->format) {