From af12a8e8a77afe1ff7ffea2c7d7b132388dc5f6c Mon Sep 17 00:00:00 2001 From: jaffer Date: Sat, 10 Dec 2022 17:27:44 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97log?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E5=87=BD=E6=95=B0=E6=8E=A5=E5=8F=A3=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E9=94=99=E8=AF=AF=E5=88=A4=E6=96=AD=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jaffer --- easyflash/src/ef_log.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/easyflash/src/ef_log.c b/easyflash/src/ef_log.c index 9d2b8c6..c6e8718 100644 --- a/easyflash/src/ef_log.c +++ b/easyflash/src/ef_log.c @@ -490,8 +490,14 @@ EfErrCode ef_log_read(size_t index, uint32_t *log, size_t size) { return result; } - EF_ASSERT(size % 4 == 0); - EF_ASSERT(index < cur_using_size); + if (size % 4 == 0) { + EF_DEBUG("Error: size must be word aligned."); + return EF_READ_ERR; + } + if (index < cur_using_size) { + EF_DEBUG("Error: index out of ranges, current using size is %d", cur_using_size); + return EF_READ_ERR; + } if (index + size > cur_using_size) { EF_DEBUG("Warning: Log read size out of bound. Cut read size.\n");