]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
anvil: Fix memory leak when unused alt username field was reused for another field
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 14 May 2024 17:53:54 +0000 (20:53 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 14 May 2024 17:53:54 +0000 (20:53 +0300)
src/anvil/connect-limit.c

index 52f785434733b66394bda0d3de5764bb71e08b0f..f3a934a792673fa6a5d075e13a62aa48098c795f 100644 (file)
@@ -277,8 +277,12 @@ alt_username_field_ref(struct connect_limit *limit, const char *name)
                                  old_count,
                                  sizeof(limit->alt_username_hashes[0]) *
                                  I_MAX((idx+1), old_count));
-               hash_table_create(&limit->alt_username_hashes[idx],
-                                 default_pool, 0, str_hash, strcmp);
+               if (!hash_table_is_created(limit->alt_username_hashes[idx])) {
+                       hash_table_create(&limit->alt_username_hashes[idx],
+                                         default_pool, 0, str_hash, strcmp);
+               } else {
+                       i_assert(hash_table_count(limit->alt_username_hashes[idx]) == 0);
+               }
        } else {
                field = array_idx_modifiable(&limit->alt_username_fields, idx);
        }