From 4ce9bc4189c859db589d0637d0c736ff306a6cc7 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan.bosch@open-xchange.com>
Date: Sun, 29 Sep 2024 01:15:15 +0200
Subject: [PATCH] lib-sieve: sieve-script - Split off
 sieve_script_update_event()

---
 src/lib-sieve/sieve-script.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/lib-sieve/sieve-script.c b/src/lib-sieve/sieve-script.c
index 48881c0c5..6a77e75a1 100644
--- a/src/lib-sieve/sieve-script.c
+++ b/src/lib-sieve/sieve-script.c
@@ -87,6 +87,18 @@ bool sieve_script_name_is_valid(const char *scriptname)
  * Script instance
  */
 
+static void sieve_script_update_event(struct sieve_script *script)
+{
+	if (script->name == NULL)
+		event_set_append_log_prefix(script->event, "script: ");
+	else {
+		event_add_str(script->event, "script_name", script->name);
+		event_set_append_log_prefix(
+			script->event, t_strdup_printf("script '%s': ",
+						       script->name));
+	}
+}
+
 void sieve_script_init(struct sieve_script *script,
 		       struct sieve_storage *storage,
 		       const struct sieve_script *script_class,
@@ -98,17 +110,11 @@ void sieve_script_init(struct sieve_script *script,
 	script->refcount = 1;
 	script->storage = storage;
 	script->location = p_strdup_empty(script->pool, location);
-	script->name = p_strdup(script->pool, name);
+	script->name = p_strdup_empty(script->pool, name);
 
 	script->event = event_create(storage->event);
-	event_add_str(script->event, "script_name", name);
 	event_add_str(script->event, "script_location", location);
-	if (name == NULL)
-		event_set_append_log_prefix(script->event, "script: ");
-	else {
-		event_set_append_log_prefix(
-			script->event, t_strdup_printf("script '%s': ", name));
-	}
+	sieve_script_update_event(script);
 
 	sieve_storage_ref(storage);
 }
-- 
GitLab