From c71f089f5efae1b4ec51988a8fcad2653e23675d Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 19 Feb 2019 10:17:45 +0200 Subject: [PATCH] lib: istream-seekable - Change stream to be blocking=TRUE after reaching EOF After EOF is reached, the stream is now fully read into file or memory. read()s can no longer return 0, so blocking=TRUE can be used. Some callers were reusing the seekable stream in places that required blocking=TRUE. Fixes at least with imapsieve vnd.dovecot report extension: Panic: file ostream.c: line 427 (o_stream_nsend_istream): assertion failed: (instream->blocking) --- src/lib/istream-seekable.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/istream-seekable.c b/src/lib/istream-seekable.c index 875bba667f..67ff65620b 100644 --- a/src/lib/istream-seekable.c +++ b/src/lib/istream-seekable.c @@ -164,6 +164,10 @@ static ssize_t read_more(struct seekable_istream *sstream) /* last one, EOF */ sstream->size = sstream->istream.istream.v_offset; sstream->istream.istream.eof = TRUE; + /* Now that EOF is reached, the stream can't return 0 + anymore. Callers can now use this stream in places + that assert that blocking==TRUE. */ + sstream->istream.istream.blocking = TRUE; unref_streams(sstream); return -1; } -- 2.47.3