From a9a2538812e3796dcba1ad5900658499fdd25acb Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan.bosch@open-xchange.com> Date: Mon, 28 Oct 2024 22:42:07 +0100 Subject: [PATCH] lib-sieve: sieve-script - Improve sieve_script_hash() --- src/lib-sieve/sieve-script.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib-sieve/sieve-script.c b/src/lib-sieve/sieve-script.c index f4c01786a..be225b736 100644 --- a/src/lib-sieve/sieve-script.c +++ b/src/lib-sieve/sieve-script.c @@ -441,9 +441,16 @@ int sieve_script_cmp(const struct sieve_script *script1, unsigned int sieve_script_hash(const struct sieve_script *script) { - i_assert(script->name != NULL); + if (script == NULL) + return 0; + + unsigned int hash = 0; + + hash ^= POINTER_CAST_TO(script->script_class, unsigned int); + hash ^= sieve_storage_hash(script->storage); + hash ^= str_hash(script->name); - return str_hash(script->name); + return hash; } /* -- GitLab