From 183c8ba43a66a3d14433b61e597b4cf14caedd8d Mon Sep 17 00:00:00 2001
From: Timo Sirainen <timo.sirainen@open-xchange.com>
Date: Wed, 22 Sep 2021 00:51:00 +0300
Subject: [PATCH] lib-sieve: sieve-binary-file - Add missing ostream finish

---
 src/lib-sieve/sieve-binary-file.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/lib-sieve/sieve-binary-file.c b/src/lib-sieve/sieve-binary-file.c
index 8eedbc233..e103fbed3 100644
--- a/src/lib-sieve/sieve-binary-file.c
+++ b/src/lib-sieve/sieve-binary-file.c
@@ -398,6 +398,12 @@ sieve_binary_save_to_stream(struct sieve_binary *sbin, struct ostream *stream)
 			return FALSE;
 	}
 
+	if (o_stream_finish(stream) <= 0) {
+		e_error(sbin->event, "save: "
+			"failed to finish output stream: %s",
+			o_stream_get_error(stream));
+		return FALSE;
+	}
 	return TRUE;
 }
 
@@ -462,6 +468,7 @@ sieve_binary_do_save(struct sieve_binary *sbin, const char *path, bool update,
 		result = -1;
 		if (error_r != NULL)
 			*error_r = SIEVE_ERROR_TEMP_FAILURE;
+		o_stream_ignore_last_errors(stream);
 	}
 	o_stream_destroy(&stream);
 
-- 
GitLab