From 7b3bb5fa6d5be0e04beb32b45b773a975256cb95 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 15 May 2022 18:01:44 +0100 Subject: [PATCH] Fixed incorrect returned span length for byte stream read --- include/etl/byte_stream.h | 2 +- test/test_byte_stream.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/etl/byte_stream.h b/include/etl/byte_stream.h index d011e630..2b75e82a 100644 --- a/include/etl/byte_stream.h +++ b/include/etl/byte_stream.h @@ -559,7 +559,7 @@ namespace etl { T* destination = start; - while (length-- != 0U) + for (size_t i = 0; i < length; ++i) { *destination++ = from_bytes(); } diff --git a/test/test_byte_stream.cpp b/test/test_byte_stream.cpp index 7333eb77..799f4295 100644 --- a/test/test_byte_stream.cpp +++ b/test/test_byte_stream.cpp @@ -920,6 +920,7 @@ namespace etl::optional > result = reader.read(output); CHECK(result.has_value()); + CHECK_EQUAL(sizeof(const int32_t), result.value().size()); CHECK_EQUAL(put_data[0], get_data[0]); CHECK_EQUAL(put_data[1], get_data[1]); CHECK_EQUAL(put_data[2], get_data[2]); @@ -944,6 +945,7 @@ namespace etl::optional > result = reader.read(get_data.data(), get_data.size()); CHECK(result.has_value()); + CHECK_EQUAL(sizeof(const int32_t), result.value().size()); CHECK_EQUAL(put_data[0], get_data[0]); CHECK_EQUAL(put_data[1], get_data[1]); CHECK_EQUAL(put_data[2], get_data[2]);