Skip to content

Commit 4733839

Browse files
authored
add assert for addition overflow on queue creation (#225)
1 parent d05b9c1 commit 4733839

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

queue.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,9 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
397397
/* Check for multiplication overflow. */
398398
configASSERT( ( uxItemSize == 0 ) || ( uxQueueLength == ( xQueueSizeInBytes / uxItemSize ) ) );
399399

400+
/* Check for addition overflow. */
401+
configASSERT( ( sizeof( Queue_t ) + xQueueSizeInBytes ) > xQueueSizeInBytes );
402+
400403
/* Allocate the queue and storage area. Justification for MISRA
401404
* deviation as follows: pvPortMalloc() always ensures returned memory
402405
* blocks are aligned per the requirements of the MCU stack. In this case

0 commit comments

Comments
 (0)