Skip to content

Commit

Permalink
global: i_stream_read_memarea() - Remove impossible ret==-2 checks
Browse files Browse the repository at this point in the history
If the stream's buffer is empty, i_stream_read_memarea() would have already
assert-crashed at this point.
  • Loading branch information
sirainen authored and Timo Sirainen committed Nov 2, 2017
1 parent 7f4bcbb commit 22ee6e1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/lib-http/http-transfer-chunked.c
Expand Up @@ -377,7 +377,8 @@ http_transfer_chunked_istream_read_data(
data = i_stream_get_data(stream->parent, &size);
if (size == 0) {
ret = i_stream_read_memarea(stream->parent);
if (ret <= 0 && (ret != -2 || stream->skip == 0)) {
if (ret <= 0) {
i_assert(ret != -2); /* 0 sized buffer can't be full */
if ( stream->parent->eof && stream->parent->stream_errno == 0 ) {
/* unexpected EOF */
io_stream_set_error(&tcstream->istream.iostream,
Expand Down
3 changes: 2 additions & 1 deletion src/lib-mail/istream-dot.c
Expand Up @@ -30,7 +30,8 @@ static int i_stream_dot_read_some(struct dot_istream *dstream)
size = i_stream_get_data_size(stream->parent);
if (size == 0) {
ret = i_stream_read_memarea(stream->parent);
if (ret <= 0 && (ret != -2 || stream->skip == 0)) {
if (ret <= 0) {
i_assert(ret != -2); /* 0 sized buffer can't be full */
if (stream->parent->stream_errno != 0) {
stream->istream.stream_errno =
stream->parent->stream_errno;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/istream-crlf.c
Expand Up @@ -20,7 +20,8 @@ static int i_stream_crlf_read_common(struct crlf_istream *cstream)
size = i_stream_get_data_size(stream->parent);
if (size == 0) {
ret = i_stream_read_memarea(stream->parent);
if (ret <= 0 && (ret != -2 || stream->skip == 0)) {
if (ret <= 0) {
i_assert(ret != -2); /* 0 sized buffer can't be full */
stream->istream.stream_errno =
stream->parent->stream_errno;
stream->istream.eof = stream->parent->eof;
Expand Down

0 comments on commit 22ee6e1

Please sign in to comment.