From 6a117056c016d9916dfa6e4a6d588a7b5df8038b Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Sun, 3 Jan 2016 16:32:27 +0100
Subject: [PATCH] lib-sieve: message body: Fixed erroneous changes to the
 message part tree structure performed when re-parsing the message.

---
 src/lib-sieve/sieve-message.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lib-sieve/sieve-message.c b/src/lib-sieve/sieve-message.c
index 10d100a3b..95d0eb50a 100644
--- a/src/lib-sieve/sieve-message.c
+++ b/src/lib-sieve/sieve-message.c
@@ -1205,12 +1205,12 @@ static int sieve_message_parts_add_missing
 						struct sieve_message_part *child = parent->children;
 						while (child->next != NULL && child != body_part)
 							child = child->next;
-						if (child->next == NULL)
+						if (child != body_part)
 							child->next = body_part;
 					}
 				}
-				last_part = body_part;
 			}
+			last_part = body_part;
 
 			/* If this is message/rfc822 content, retain the enveloping part for
 			 * storing headers as content.
-- 
GitLab