]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: i_stream_w_buffer_realloc() - avoid passing NULL to memcpy()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 1 Nov 2017 23:34:11 +0000 (01:34 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 1 Nov 2017 23:34:11 +0000 (01:34 +0200)
It happened only with size=0, so it shouldn't have mattered much.

src/lib/istream.c

index 230542d00affc408393508658507370a66c3db1c..2896110a1ea65e30e6c29965829286958e6eff66 100644 (file)
@@ -782,7 +782,10 @@ i_stream_w_buffer_realloc(struct istream_private *stream, size_t old_size)
                                       stream->buffer_size);
        } else {
                new_buffer = i_malloc(stream->buffer_size);
-               memcpy(new_buffer, stream->w_buffer, old_size);
+               if (old_size > 0) {
+                       i_assert(stream->w_buffer != NULL);
+                       memcpy(new_buffer, stream->w_buffer, old_size);
+               }
                if (stream->memarea != NULL)
                        memarea_unref(&stream->memarea);
        }