From 8d5a7f1cf424f7e8e86560cf28d1744a1e59fa4b Mon Sep 17 00:00:00 2001 From: Lucas Wennerholm Date: Thu, 9 Apr 2026 10:13:58 +0200 Subject: [PATCH] Fix uninitialized active field --- src/static_queue.c | 6 ++++++ src/static_queue.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/static_queue.c b/src/static_queue.c index b7f18b5..beded48 100644 --- a/src/static_queue.c +++ b/src/static_queue.c @@ -33,6 +33,10 @@ int32_t staticQueueInit(staticQueue_t* queue, uint32_t node_size, staticQueueItem_t* first_item) { + if (queue_size == 0) { + return STATIC_QUEUE_INVALID; + } + queue->head = first_item; queue->tail = first_item; queue->first_item = first_item; @@ -40,11 +44,13 @@ int32_t staticQueueInit(staticQueue_t* queue, staticQueueItem_t* item = first_item; for (uint32_t i = 0; i < queue_size - 1; i++) { + item->active = false; item->next = (staticQueueItem_t*)((uint8_t*)item + node_size); item->next->last = item; item = item->next; } + item->active = false; first_item->last = item; item->next = first_item; diff --git a/src/static_queue.h b/src/static_queue.h index 8fdc82d..9bc35ee 100644 --- a/src/static_queue.h +++ b/src/static_queue.h @@ -83,6 +83,7 @@ typedef enum { STATIC_QUEUE_FULL = -401, STATIC_QUEUE_EMPTY = -402, STATIC_QUEUE_NOT_IN_QUEUE = -403, + STATIC_QUEUE_INVALID = -404, } queueErr_t; typedef enum {