From: Timo Sirainen Date: Wed, 2 Sep 2009 21:45:35 +0000 (-0400) Subject: settings: Don't crash if no namespaces or services have been created. X-Git-Tag: 2.0.alpha1~195 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1dd7e17bcb59e158457eed755223e1981a1eed96;p=thirdparty%2Fdovecot%2Fcore.git settings: Don't crash if no namespaces or services have been created. --HG-- branch : HEAD --- diff --git a/src/lib-storage/mail-storage-settings.c b/src/lib-storage/mail-storage-settings.c index 2ef4e34daf..0c3e74f668 100644 --- a/src/lib-storage/mail-storage-settings.c +++ b/src/lib-storage/mail-storage-settings.c @@ -347,7 +347,13 @@ static bool namespace_settings_check(void *_set, pool_t pool ATTR_UNUSED, } if (ns->alias_for != NULL) { - namespaces = array_get(&ns->user_set->namespaces, &count); + if (array_is_created(&ns->user_set->namespaces)) { + namespaces = array_get(&ns->user_set->namespaces, + &count); + } else { + namespaces = NULL; + count = 0; + } for (i = 0; i < count; i++) { if (strcmp(namespaces[i]->prefix, ns->alias_for) == 0) break; diff --git a/src/master/master-settings.c b/src/master/master-settings.c index ed99bc9351..b1293262af 100644 --- a/src/master/master-settings.c +++ b/src/master/master-settings.c @@ -278,11 +278,12 @@ master_settings_verify(void *_set, pool_t pool, const char **error_r) /* check that we have at least one service. the actual service structure validity is checked later while creating them. */ - services = array_get(&set->services, &count); - if (count == 0) { + if (!array_is_created(&set->services) || + array_count(&set->services) == 0) { *error_r = "No services defined"; return FALSE; } + services = array_get(&set->services, &count); for (i = 0; i < count; i++) { if (*services[i]->name == '\0') { *error_r = t_strdup_printf(