diff --git a/lib/cmp_icu.c b/lib/cmp_icu.c
index 79d1a64f075989c59700f5ceb865048635d64a04..5995afb13f27b09cc7cd652c5ec87a9dc9a781c7 100644
--- a/lib/cmp_icu.c
+++ b/lib/cmp_icu.c
@@ -142,7 +142,7 @@ uint32_t cmp_cfg_icu_buffers(struct cmp_cfg *cfg, void *data_to_compress,
 	data_size = cmp_cal_size_of_data(compressed_data_len_samples, cfg->data_type);
 	hdr_size = cmp_ent_cal_hdr_size(cfg->data_type, cfg->cmp_mode == CMP_MODE_RAW);
 
-	if ((data_size + hdr_size) > CMP_ENTITY_MAX_SIZE) {
+	if ((data_size + hdr_size) > CMP_ENTITY_MAX_SIZE || data_size > CMP_ENTITY_MAX_SIZE) {
 		debug_print("Error: The buffer for the compressed data is too large to fit in a compression entity.\n");
 		return 0;
 	}