From: Timo Sirainen Date: Thu, 22 Oct 2020 09:22:40 +0000 (+0300) Subject: lib: i_stream_read() - Don't create empty snapshots X-Git-Tag: 2.3.14.rc1~283 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8299232acbd010177d8048071b9ecff0a8620704;p=thirdparty%2Fdovecot%2Fcore.git lib: i_stream_read() - Don't create empty snapshots This allows the read() implementation to read data into the existing memarea. Otherwise a new memarea might have to be created because the old one is referenced by the snapshot. --- diff --git a/src/lib/istream.c b/src/lib/istream.c index 4b5e810df0..06fd93e8ca 100644 --- a/src/lib/istream.c +++ b/src/lib/istream.c @@ -266,8 +266,10 @@ ssize_t i_stream_read(struct istream *stream) } #endif - _stream->prev_snapshot = - _stream->snapshot(_stream, _stream->prev_snapshot); + if (_stream->skip != _stream->pos || _stream->prev_snapshot != NULL) { + _stream->prev_snapshot = + _stream->snapshot(_stream, _stream->prev_snapshot); + } ret = i_stream_read_memarea(stream); if (ret > 0) i_stream_snapshot_free(&_stream->prev_snapshot);