From 3f01d89d02522c38f9a6956395e76c76feadf06a Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan.bosch@open-xchange.com>
Date: Sun, 11 Apr 2021 11:51:33 +0200
Subject: [PATCH] lib-sieve: sieve-result - Avoid use of
 result->last_attempted_action in sieve_result_print().

---
 src/lib-sieve/sieve-result.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/lib-sieve/sieve-result.c b/src/lib-sieve/sieve-result.c
index 7750dddcf..614fc5f21 100644
--- a/src/lib-sieve/sieve-result.c
+++ b/src/lib-sieve/sieve-result.c
@@ -794,11 +794,7 @@ bool sieve_result_print(struct sieve_result *result,
 	struct sieve_action act_keep = result->keep_action;
 	struct sieve_result_print_env penv;
 	bool implicit_keep = TRUE, printed_any = FALSE;
-	struct sieve_result_action *rac, *actions_head;
-
-	actions_head = (result->last_attempted_action == NULL ?
-			result->actions_head :
-			result->last_attempted_action->next);
+	struct sieve_result_action *rac;
 
 	if (keep != NULL)
 		*keep = FALSE;
@@ -811,11 +807,16 @@ bool sieve_result_print(struct sieve_result *result,
 
 	sieve_result_printf(&penv, "\nPerformed actions:\n\n");
 
-	rac = actions_head;
+	rac = result->actions_head;
 	while (rac != NULL) {
 		bool impl_keep = TRUE;
 		const struct sieve_action *act = &rac->action;
 
+		if (act->exec_seq < result->exec_seq) {
+			rac = rac->next;
+			continue;
+		}
+
 		if (rac->action.keep && keep != NULL)
 			*keep = TRUE;
 
-- 
GitLab