]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-settings: Require pool_offset1 to be always set
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sun, 14 May 2023 21:36:18 +0000 (00:36 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 20 Nov 2023 12:22:31 +0000 (14:22 +0200)
src/config/test-config-parser.c
src/lib-settings/settings-parser.c
src/lib-settings/settings-parser.h

index 02a82daa2d6aded3527a3bf131c58a2413f0f6ee..1c4d93519e8abe8155abe199b94385a8c8f1db4c 100644 (file)
@@ -15,6 +15,7 @@ static const struct config_service test_config_all_services[] = { { NULL, NULL }
 const struct config_service *config_all_services = test_config_all_services;
 
 struct test_settings {
+       pool_t pool;
        const char *key;
        const char *key2;
        const char *key3;
@@ -66,6 +67,7 @@ const struct setting_parser_info test_settings_root = {
        .defaults = &test_settings_defaults,
 
        .struct_size = sizeof(struct test_settings),
+       .pool_offset1 = 1 + offsetof(struct test_settings, pool),
 };
 
 static const struct setting_parser_info *const roots[] = {
index 80762d91724b2da50e10797360a7fbfd1c42bf6d..51b4b2113d3578628a13d4638dd3e15b7ccf6e26 100644 (file)
@@ -998,10 +998,9 @@ static void *settings_dup_full(const struct setting_parser_info *info,
                setting_copy(def->type, src, dest, pool, keep_values);
        }
 
-       if (info->pool_offset1 > 0) {
-               pool_t *pool_p = PTR_OFFSET(dest_set, info->pool_offset1 - 1);
-               *pool_p = pool;
-       }
+       i_assert(info->pool_offset1 > 0);
+       pool_t *pool_p = PTR_OFFSET(dest_set, info->pool_offset1 - 1);
+       *pool_p = pool;
        return dest_set;
 }
 
index 7cc2e653d4cdc4c9862a317dd1bcca696d7adf52..ff35090547b299f04c93d0b6eab93ed1420a14ca 100644 (file)
@@ -113,7 +113,7 @@ struct setting_parser_info {
        size_t type_offset1; /* type_offset+1. 0=nonexistent. */
        size_t struct_size;
 
-       size_t pool_offset1; /* pool_offset+1. 0=nonexistent. */
+       size_t pool_offset1; /* 1 + offset to pool_t field */
 
        bool (*check_func)(void *set, pool_t pool, const char **error_r);
        /* The event parameter can be used with settings_get*() to access other