changeset 17929:c36cfd735d60

lib: Fixed assert-crash in o_stream_send_istream() if input stream was the one that failed.
author Timo Sirainen <tss@iki.fi>
date Thu, 09 Oct 2014 18:40:54 +0300
parents 193c82411d73
children af382aaad0e8
files src/lib/ostream.c
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/ostream.c	Thu Oct 09 18:27:14 2014 +0300
+++ b/src/lib/ostream.c	Thu Oct 09 18:40:54 2014 +0300
@@ -329,9 +329,12 @@
 	o_stream_clear_error(outstream);
 	ret = _outstream->send_istream(_outstream, instream);
 	if (unlikely(ret < 0)) {
-		i_assert(outstream->stream_errno != 0);
-		outstream->last_failed_errno = outstream->stream_errno;
-		errno = outstream->stream_errno;
+		if (outstream->stream_errno != 0) {
+			outstream->last_failed_errno = outstream->stream_errno;
+			errno = outstream->stream_errno;
+		} else {
+			i_assert(instream->stream_errno != 0);
+		}
 	}
 	return ret;
 }