From 6187310c4df06ee17cae0d709b54f7fe3f43e05c Mon Sep 17 00:00:00 2001
From: Dominik Loidolt <dominik.loidolt@univie.ac.at>
Date: Wed, 28 Feb 2024 09:56:39 +0100
Subject: [PATCH] Fix bug when compressing 0 samples

---
 lib/common/cmp_data_types.c | 2 +-
 lib/icu_compress/cmp_icu.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/common/cmp_data_types.c b/lib/common/cmp_data_types.c
index d6283ce..7c95c9a 100644
--- a/lib/common/cmp_data_types.c
+++ b/lib/common/cmp_data_types.c
@@ -943,7 +943,7 @@ int be_to_cpu_chunk(uint8_t *chunk, size_t chunk_size)
 	if (chunk_size < COLLECTION_HDR_SIZE)
 		return -1;
 
-	while (col_p < chunk + chunk_size - COLLECTION_HDR_SIZE) {
+	while (col_p <= chunk + chunk_size - COLLECTION_HDR_SIZE) {
 		struct collection_hdr *col_hdr = (struct collection_hdr *)col_p;
 		enum cmp_data_type data_type = convert_subservice_to_cmp_data_type(cmp_col_get_subservice(col_hdr));
 		uint32_t data_size = cmp_col_get_data_length(col_hdr);
diff --git a/lib/icu_compress/cmp_icu.c b/lib/icu_compress/cmp_icu.c
index 8e67c43..1ec466d 100644
--- a/lib/icu_compress/cmp_icu.c
+++ b/lib/icu_compress/cmp_icu.c
@@ -2132,7 +2132,7 @@ static int compress_data_internal(const struct cmp_cfg *cfg, int stream_len)
 		return stream_len;
 
 	if (cfg->samples == 0) /* nothing to compress we are done*/
-		return 0;
+		return stream_len;
 
 	if (stream_len & 0x7) {
 		debug_print("Error: The stream_len parameter must be a multiple of 8.\n");
-- 
GitLab