From: Timo Sirainen Date: Mon, 9 Jul 2018 13:23:10 +0000 (+0300) Subject: lib: o_stream_close() - Don't reset error checking on automatic flush X-Git-Tag: 2.4.0~1450 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4b1e2a465c9f637ffe68b69c0ba8d28e46354860;p=thirdparty%2Fdovecot%2Fcore.git lib: o_stream_close() - Don't reset error checking on automatic flush Otherwise it will be difficult to find missing o_stream_flush() calls. The missing error handling would be found only when the flushing fails, which would result in assert-crash. This is how the code was originally intended to behave. Broken by 5ec4fc44e8d4e2160f07b1a7f4fce1ccfec3f6c1 --- diff --git a/src/lib/ostream.c b/src/lib/ostream.c index 19ac1846ce..11b358ff1d 100644 --- a/src/lib/ostream.c +++ b/src/lib/ostream.c @@ -55,9 +55,17 @@ static void o_stream_close_full(struct ostream *stream, bool close_parents) complexity for many callers. Just require that at this point after flushing there isn't anything in the output buffer or that we're ignoring all errors. */ + bool last_errors_not_checked = + stream->real_stream->last_errors_not_checked; + if (o_stream_flush(stream) == 0) i_assert(stream->real_stream->error_handling_disabled); + /* We don't want this auto-flushing to remove the need for + proper error checking. */ + if (last_errors_not_checked) + stream->real_stream->last_errors_not_checked = TRUE; + if (!stream->closed && !stream->real_stream->closing) { /* first mark the stream as being closed so the o_stream_copy_error_from_parent() won't recurse us back