From: Timo Sirainen Date: Thu, 2 Nov 2017 20:57:00 +0000 (+0200) Subject: lib: istream - Don't leak snapshot memory if close() triggers a read X-Git-Tag: 2.3.0.rc1~590 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=30517c760897cc4f249da1830ae1996f4d7b5aea;p=thirdparty%2Fdovecot%2Fcore.git lib: istream - Don't leak snapshot memory if close() triggers a read Also move the line_str freeing just before stream is freed. That didn't cause any known memory leaks though. --- diff --git a/src/lib/istream.c b/src/lib/istream.c index 2896110a1e..905914c470 100644 --- a/src/lib/istream.c +++ b/src/lib/istream.c @@ -57,12 +57,10 @@ void i_stream_unref(struct istream **stream) _stream = (*stream)->real_stream; - if (_stream->iostream.refcount == 1) { + if (!io_stream_unref(&(*stream)->real_stream->iostream)) { if (_stream->line_str != NULL) str_free(&_stream->line_str); i_stream_snapshot_free(&_stream->prev_snapshot); - } - if (!io_stream_unref(&(*stream)->real_stream->iostream)) { i_stream_unref(&(*stream)->real_stream->parent); io_stream_free(&(*stream)->real_stream->iostream); }