diff --git a/src/utils/stream.c b/src/utils/stream.c index 9ab297c..8124c12 100644 --- a/src/utils/stream.c +++ b/src/utils/stream.c @@ -47,11 +47,11 @@ uint32_t stream_read(stream_T* stream, void* buffer_out, uint32_t n) { uint32_t num_bottom; if (stream->pos_sender > stream->pos_receiver) { - num_top = MIN(n, stream->pos_sender - stream->pos_receiver - 1); + num_top = MIN(n, stream->pos_sender - stream->pos_receiver); num_bottom = 0; } else { num_top = MIN(n, stream->size - stream->pos_receiver); - num_bottom = MIN(n - num_top, stream->pos_sender - 1); + num_bottom = MIN(n - num_top, stream->pos_sender); } memory_copy(&stream->buffer[stream->pos_receiver], buffer_out, num_top);