]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: i_stream_read() - Don't create empty snapshots
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 22 Oct 2020 09:22:40 +0000 (12:22 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Thu, 3 Dec 2020 13:08:54 +0000 (13:08 +0000)
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.

src/lib/istream.c

index 4b5e810df03c541ce8cee860e9e79acdee74ba6a..06fd93e8ca28ec4aae44127c2412a5d0d1de83f4 100644 (file)
@@ -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);