From: Timo Sirainen Date: Tue, 20 Oct 2009 22:04:06 +0000 (-0400) Subject: lib-settings: Allow settings parsers with zero byte setting structures. X-Git-Tag: 2.0.alpha2~53 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c199bd2fd329ba0e80a5989d34df06bb43216c5e;p=thirdparty%2Fdovecot%2Fcore.git lib-settings: Allow settings parsers with zero byte setting structures. --HG-- branch : HEAD --- diff --git a/src/lib-settings/settings-parser.c b/src/lib-settings/settings-parser.c index 9e6117a8ce..f5dfb1eb63 100644 --- a/src/lib-settings/settings-parser.c +++ b/src/lib-settings/settings-parser.c @@ -127,6 +127,9 @@ settings_parser_init_list(pool_t set_pool, ctx->roots = p_new(ctx->parser_pool, struct setting_link, count); for (i = 0; i < count; i++) { ctx->roots[i].info = roots[i]; + if (roots[i]->struct_size == 0) + continue; + ctx->roots[i].set_struct = p_malloc(ctx->set_pool, roots[i]->struct_size); if ((flags & SETTINGS_PARSER_FLAG_TRACK_CHANGES) != 0) { @@ -964,6 +967,9 @@ void *settings_dup(const struct setting_parser_info *info, void *dest_set, *dest, *const *children; unsigned int i, count; + if (info->struct_size == 0) + return NULL; + /* don't just copy everything from set to dest_set. it may contain some non-setting fields allocated from the original pool. */ dest_set = p_malloc(pool, info->struct_size); @@ -1002,7 +1008,7 @@ settings_changes_dup(const struct setting_parser_info *info, void *dest_set, *dest, *const *children; unsigned int i, count; - if (change_set == NULL) + if (change_set == NULL || info->struct_size == 0) return NULL; dest_set = p_malloc(pool, info->struct_size); @@ -1257,6 +1263,9 @@ settings_changes_init(const struct setting_parser_info *info, void *dest_set, *set, *const *children; unsigned int i, count; + if (info->struct_size == 0) + return NULL; + dest_set = p_malloc(pool, info->struct_size); for (def = info->defines; def->key != NULL; def++) { if (def->type != SET_DEFLIST)