This is an automated email from the ASF dual-hosted git repository.
kasjer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 82e2383ba sys/log: Fix storage info for log_cbmem
82e2383ba is described below
commit 82e2383bac0ef0428f60e78956d35b27d15558bf
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Mon Jun 22 11:10:39 2026 +0200
sys/log: Fix storage info for log_cbmem
When log_cbmem is empty, (nothing was logged yet)
storage_info would crash due to NULL pointer
dereference object used in arithemtic.
Now code checks for NULL and reports whole size
of the buffer during storage_info call.
Signed-off-by: Jerzy Kasenberg <[email protected]>
---
sys/log/full/src/log_cbmem.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/sys/log/full/src/log_cbmem.c b/sys/log/full/src/log_cbmem.c
index 02cd3503f..dada4951e 100644
--- a/sys/log/full/src/log_cbmem.c
+++ b/sys/log/full/src/log_cbmem.c
@@ -242,14 +242,16 @@ log_cbmem_storage_info(struct log *log, struct
log_storage_info *info)
{
struct cbmem *cbmem;
uint32_t size;
- uint32_t used;
+ uint32_t used = 0;
cbmem = (struct cbmem *)log->l_arg;
size = cbmem->c_buf_end - cbmem->c_buf;
- used = (uintptr_t)cbmem->c_entry_end + cbmem->c_entry_end->ceh_len -
- (uintptr_t)cbmem->c_entry_start;
+ if (cbmem->c_buf_cur_end) {
+ used = (uintptr_t)cbmem->c_entry_end + cbmem->c_entry_end->ceh_len -
+ (uintptr_t)cbmem->c_entry_start;
+ }
if ((int32_t)used < 0) {
used += size;
}