]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: istream - Don't leak snapshot memory if close() triggers a read
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 2 Nov 2017 20:57:00 +0000 (22:57 +0200)
committerTimo Sirainen <tss@dovecot.fi>
Thu, 2 Nov 2017 22:25:01 +0000 (00:25 +0200)
Also move the line_str freeing just before stream is freed. That didn't
cause any known memory leaks though.

src/lib/istream.c

index 2896110a1ea65e30e6c29965829286958e6eff66..905914c4703ebc188d6c061500b4e4ef143fb151 100644 (file)
@@ -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);
        }