Skip to content

Commit fefa91f

Browse files
authored
Merge pull request #3898 from c1728p9/fix_heap_size_calculation
Prevent underflow in heap size calculation
2 parents 93b6a21 + 88f879d commit fefa91f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ void set_stack_heap(void) {
478478
mbed_stack_isr_start = ISR_STACK_START;
479479
#else
480480
/* Interrupt stack - reserve space at the end of the free block */
481-
mbed_stack_isr_size = ISR_STACK_SIZE;
481+
mbed_stack_isr_size = ISR_STACK_SIZE < free_size ? ISR_STACK_SIZE : free_size;
482482
mbed_stack_isr_start = free_start + free_size - mbed_stack_isr_size;
483483
free_size -= mbed_stack_isr_size;
484484
#endif

0 commit comments

Comments
 (0)