From fa39c427573ada77265b833db687ca7e854794a1 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 27 Oct 2017 21:32:10 +0300 Subject: [PATCH] lib: i_stream_compress() - assert-crash if trying to compress shared memarea The caller is always expected to check the refcount before calling this. --- src/lib/istream.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/istream.c b/src/lib/istream.c index 937a6ddde8..1173ac929c 100644 --- a/src/lib/istream.c +++ b/src/lib/istream.c @@ -750,6 +750,9 @@ int i_stream_read_data(struct istream *stream, const unsigned char **data_r, void i_stream_compress(struct istream_private *stream) { + i_assert(stream->memarea == NULL || + memarea_get_refcount(stream->memarea) == 1); + if (stream->skip != stream->pos) { memmove(stream->w_buffer, stream->w_buffer + stream->skip, stream->pos - stream->skip); -- 2.47.3