From: Sean Bright Date: Fri, 1 Sep 2017 14:51:06 +0000 (-0400) Subject: app_directory: Handle a NULL mailbox without crashing X-Git-Tag: 13.18.0-rc1~68^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f4863d4f9b707ba66bf94302f641d3aee438f7c;p=thirdparty%2Fasterisk.git app_directory: Handle a NULL mailbox without crashing ASTERISK-27241 #close Reported by: David Moore Change-Id: Ibbbca85517b04c315406ebfe3b6f7e0763daedc6 --- diff --git a/apps/app_directory.c b/apps/app_directory.c index b75e857639..9cfcbf862a 100644 --- a/apps/app_directory.c +++ b/apps/app_directory.c @@ -511,6 +511,11 @@ static struct ast_config *realtime_directory(char *context) const char *mailbox = ast_variable_retrieve(rtdata, category, "mailbox"); const char *ctx = ast_variable_retrieve(rtdata, category, "context"); + if (ast_strlen_zero(mailbox)) { + ast_debug(3, "Skipping result with missing or empty mailbox\n"); + continue; + } + fullname = ast_variable_retrieve(rtdata, category, "fullname"); hidefromdir = ast_variable_retrieve(rtdata, category, "hidefromdir"); if (ast_true(hidefromdir)) { @@ -531,7 +536,7 @@ static struct ast_config *realtime_directory(char *context) /* Does the context exist within the config file? If not, make one */ if (!(cat = ast_category_get(cfg, ctx, NULL))) { - if (!(cat = ast_category_new(ctx, "", 99999))) { + if (!(cat = ast_category_new_dynamic(ctx))) { ast_log(LOG_WARNING, "Out of memory\n"); ast_config_destroy(cfg); if (rtdata) {