]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: return non-NULL pointer in i_stream_get_data when size is 0
authorMartti Rannanjärvi <martti.rannanjarvi@dovecot.fi>
Fri, 22 Jul 2016 07:47:20 +0000 (10:47 +0300)
committerGitLab <gitlab@git.dovecot.net>
Mon, 1 Aug 2016 22:09:17 +0000 (01:09 +0300)
src/lib/istream.c
src/lib/istream.h

index 2a0b4131f5d6465a0a206f38f9bc92090ae31b21..b08ae4f3c80b63d954de16629c0ea7d36999e708 100644 (file)
@@ -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;
index d722b047d17d3323f3170932c24e5d915d03c954..dff7ffd26a3384b66973b16422e51b95c9a8b48d 100644 (file)
@@ -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