From: Martti Rannanjärvi Date: Fri, 22 Jul 2016 07:47:20 +0000 (+0300) Subject: lib: return non-NULL pointer in i_stream_get_data when size is 0 X-Git-Tag: 2.3.0.rc1~3277 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6657aee0bb6c603b4ee5111388b93c1a8a9ad680;p=thirdparty%2Fdovecot%2Fcore.git lib: return non-NULL pointer in i_stream_get_data when size is 0 --- diff --git a/src/lib/istream.c b/src/lib/istream.c index 2a0b4131f5..b08ae4f3c8 100644 --- a/src/lib/istream.c +++ b/src/lib/istream.c @@ -503,7 +503,7 @@ i_stream_get_data(struct istream *stream, size_t *size_r) if (_stream->skip >= _stream->pos) { *size_r = 0; - return NULL; + return &uchar_nul; } if (i_stream_is_buffer_invalid(_stream)) { @@ -528,7 +528,7 @@ i_stream_get_data(struct istream *stream, size_t *size_r) _stream->skip = _stream->pos = 0; stream->eof = FALSE; } - return NULL; + return &uchar_nul; } *size_r = _stream->pos - _stream->skip; diff --git a/src/lib/istream.h b/src/lib/istream.h index d722b047d1..dff7ffd26a 100644 --- a/src/lib/istream.h +++ b/src/lib/istream.h @@ -166,8 +166,7 @@ char *i_stream_read_next_line(struct istream *stream); CRLF (instead of LF). */ bool i_stream_last_line_crlf(struct istream *stream); -/* Returns pointer to beginning of read data, or NULL if there's no data - buffered. */ +/* Returns pointer to beginning of read data. */ const unsigned char *i_stream_get_data(struct istream *stream, size_t *size_r); size_t i_stream_get_data_size(struct istream *stream); /* Like i_stream_get_data(), but returns non-const data. This only works with