From: Timo Sirainen Date: Mon, 9 Nov 2020 15:35:15 +0000 (+0200) Subject: lib: istream-chain - Avoid NULL pointer arithmetic X-Git-Tag: 2.3.14.rc1~368 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=73ade3503a33151ea739aef04478d1ad7e42c00d;p=thirdparty%2Fdovecot%2Fcore.git lib: istream-chain - Avoid NULL pointer arithmetic Even though it was only doing +0. Fixes: runtime error: applying zero offset to null pointer --- diff --git a/src/lib/istream-chain.c b/src/lib/istream-chain.c index 89fc86023a..e931487836 100644 --- a/src/lib/istream-chain.c +++ b/src/lib/istream-chain.c @@ -181,9 +181,12 @@ static bool i_stream_chain_skip(struct chain_istream *cstream) bytes_skipped -= cstream->prev_stream_left; cstream->prev_stream_left = 0; } - stream->pos -= bytes_skipped; - stream->skip -= bytes_skipped; - stream->buffer += bytes_skipped; + if (bytes_skipped > 0) { + i_assert(stream->buffer != NULL); + stream->pos -= bytes_skipped; + stream->skip -= bytes_skipped; + stream->buffer += bytes_skipped; + } cstream->prev_skip = stream->skip; if (link == NULL || link->eof) { i_assert(bytes_skipped == 0);