From: Timo Sirainen Date: Sat, 10 Dec 2011 05:57:16 +0000 (+0200) Subject: zlib: Avoid assert-crashing if parent ostream's write had failed earlier. X-Git-Tag: 2.1.rc2~63 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b51bac20ad24b42eb157390e3207ea4e3fe0807a;p=thirdparty%2Fdovecot%2Fcore.git zlib: Avoid assert-crashing if parent ostream's write had failed earlier. --- diff --git a/src/plugins/zlib/ostream-bzlib.c b/src/plugins/zlib/ostream-bzlib.c index 070cdc3c46..5c38978700 100644 --- a/src/plugins/zlib/ostream-bzlib.c +++ b/src/plugins/zlib/ostream-bzlib.c @@ -69,7 +69,12 @@ static int o_stream_bzlib_send_flush(struct bzlib_ostream *zstream) bool done = FALSE; int ret; - i_assert(zs->avail_in == 0); + if (zs->avail_in != 0) { + i_assert(zstream->ostream.ostream.last_failed_errno != 0); + zstream->ostream.ostream.stream_errno = + zstream->ostream.ostream.last_failed_errno; + return -1; + } if (zstream->flushed) return 0; diff --git a/src/plugins/zlib/ostream-zlib.c b/src/plugins/zlib/ostream-zlib.c index a834afebea..7958526a0f 100644 --- a/src/plugins/zlib/ostream-zlib.c +++ b/src/plugins/zlib/ostream-zlib.c @@ -129,7 +129,12 @@ static int o_stream_zlib_send_flush(struct zlib_ostream *zstream) bool done = FALSE; int ret; - i_assert(zs->avail_in == 0); + if (zs->avail_in != 0) { + i_assert(zstream->ostream.ostream.last_failed_errno != 0); + zstream->ostream.ostream.stream_errno = + zstream->ostream.ostream.last_failed_errno; + return -1; + } if (zstream->flushed) return 0;