From: Stephan Bosch Date: Wed, 13 Jul 2016 07:46:08 +0000 (+0200) Subject: Calling i_stream_next_line() on a chain stream would sometimes erroneously use the... X-Git-Tag: 2.2.26~466 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b4796b3100ce0c93f43060c42f314445442c9d0e;p=thirdparty%2Fdovecot%2Fcore.git Calling i_stream_next_line() on a chain stream would sometimes erroneously use the stream->w_buffer. It used the wrong check to assess whether the w_buffer is usable. The chain stream only uses the w_buffer when partial stream data needs to be merged. Otherwise, a parent stream's buffer is used directly. However, this does not mean that w_buffer will be NULL in that case, which is what i_stream_next_line() assumed. --- diff --git a/src/lib/istream.c b/src/lib/istream.c index aa95c1cb9d..3f914f5515 100644 --- a/src/lib/istream.c +++ b/src/lib/istream.c @@ -386,7 +386,7 @@ static char *i_stream_next_line_finish(struct istream_private *stream, size_t i) stream->line_crlf = FALSE; } - if (stream->w_buffer != NULL) { + if (stream->buffer == stream->w_buffer) { /* modify the buffer directly */ stream->w_buffer[end] = '\0'; ret = (char *)stream->w_buffer + stream->skip;