]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-settings: Allow settings parsers with zero byte setting structures.
authorTimo Sirainen <tss@iki.fi>
Tue, 20 Oct 2009 22:04:06 +0000 (18:04 -0400)
committerTimo Sirainen <tss@iki.fi>
Tue, 20 Oct 2009 22:04:06 +0000 (18:04 -0400)
--HG--
branch : HEAD

src/lib-settings/settings-parser.c

index 9e6117a8cec5ee6272f665f41890beebc2c81ab3..f5dfb1eb6384c9be7f74d8d163b5ba9fdcb2dc81 100644 (file)
@@ -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)