Mercurial > dovecot > core-2.2
changeset 9262:7604073a4ccc HEAD
settings_parser_dup() fixes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 11 May 2009 20:09:33 -0400 |
parents | 5e80d667a827 |
children | 5d0a69504867 |
files | src/lib-settings/settings-parser.c |
diffstat | 1 files changed, 15 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-settings/settings-parser.c Mon May 11 20:08:39 2009 -0400 +++ b/src/lib-settings/settings-parser.c Mon May 11 20:09:33 2009 -0400 @@ -1035,7 +1035,7 @@ { struct setting_link *new_link; void *const *old_sets, **new_sets; - unsigned int i, count; + unsigned int i, count, count2; size_t diff; new_link = hash_table_lookup(links, old_link); @@ -1052,19 +1052,22 @@ /* find the array from parent struct */ diff = (char *)old_link->array - (char *)old_link->parent->set_struct; - i_assert(diff + sizeof(*old_link->array) <= old_link->info->struct_size); + i_assert(diff + sizeof(*old_link->array) <= old_link->parent->info->struct_size); new_link->array = PTR_OFFSET(new_link->parent->set_struct, diff); - /* find our struct from array */ - old_sets = array_get(old_link->array, &count); - new_sets = array_get_modifiable(new_link->array, &count); - for (i = 0; i < count; i++) { - if (old_sets[i] == old_link->set_struct) { - new_link->set_struct = new_sets[i]; - break; + if (old_link->set_struct != NULL) { + /* find our struct from array */ + old_sets = array_get(old_link->array, &count); + new_sets = array_get_modifiable(new_link->array, &count2); + i_assert(count == count2); + for (i = 0; i < count; i++) { + if (old_sets[i] == old_link->set_struct) { + new_link->set_struct = new_sets[i]; + break; + } } + i_assert(i < count); } - i_assert(i < count); hash_table_insert(links, old_link, new_link); return new_link; } @@ -1081,7 +1084,7 @@ new_ctx = p_new(new_pool, struct setting_parser_context, 1); new_ctx->set_pool = new_pool; - new_ctx->parser_pool = pool_alloconly_create("settings parser", 1024); + new_ctx->parser_pool = pool_alloconly_create("settings parser", 2048); new_ctx->flags = old_ctx->flags; new_ctx->str_vars_are_expanded = old_ctx->str_vars_are_expanded; new_ctx->linenum = old_ctx->linenum; @@ -1110,7 +1113,7 @@ hash_table_create(default_pool, new_ctx->parser_pool, 0, str_hash, (hash_cmp_callback_t *)strcmp); - iter = hash_table_iterate_init(new_ctx->links); + iter = hash_table_iterate_init(old_ctx->links); while (hash_table_iterate(iter, &key, &value)) { new_link = settings_link_get_new(new_ctx, links, value); hash_table_insert(new_ctx->links,