From d493ebc64f28b9724ff5c01c24db644f591a435d Mon Sep 17 00:00:00 2001 From: antifallobst Date: Tue, 2 May 2023 00:42:09 +0200 Subject: [PATCH] fix (stream): fixed bug that allowed reading nonexistent data --- src/utils/stream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/stream.c b/src/utils/stream.c index 8124c12..9972598 100644 --- a/src/utils/stream.c +++ b/src/utils/stream.c @@ -20,8 +20,6 @@ void stream_destruct(stream_T* stream) { memory_free(stream); } -#include "utils/logger.h" - uint32_t stream_write(stream_T* stream, void* buffer_in, uint32_t n) { uint32_t num_top; uint32_t num_bottom; @@ -43,6 +41,8 @@ uint32_t stream_write(stream_T* stream, void* buffer_in, uint32_t n) { } uint32_t stream_read(stream_T* stream, void* buffer_out, uint32_t n) { + if (stream->pos_sender == stream->pos_receiver) return 0; + uint32_t num_top; uint32_t num_bottom;