From b51bac20ad24b42eb157390e3207ea4e3fe0807a Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 10 Dec 2011 07:57:16 +0200 Subject: [PATCH] zlib: Avoid assert-crashing if parent ostream's write had failed earlier. --- src/plugins/zlib/ostream-bzlib.c | 7 ++++++- src/plugins/zlib/ostream-zlib.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) 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; -- 2.47.3