]> begriffs open source - freertos/commit
Fix NULL pointer dereference in vPortGetHeapStats
authorGaurav Aggarwal <aggarg@amazon.com>
Thu, 4 Aug 2022 11:11:33 +0000 (16:41 +0530)
committerPaul Bartell <paul.bartell@gmail.com>
Thu, 4 Aug 2022 16:57:59 +0000 (09:57 -0700)
commit618e165fa738e61ede4668c6907f8ecc85864d36
treef5ceb1dd84f1c19467fb619e0634f11e5976fecd
parentdc9c034c854e3a6e004062a84806a07af6008a34
Fix NULL pointer dereference in vPortGetHeapStats

When the heap is exhausted (no free block), start and end markers are
the only blocks present in the free block list:

     +---------------+     +-----------> NULL
     |               |     |
     |               V     |
+ ----- +            + ----- +
|   |   |            |   |   |
|   |   |            |   |   |
+ ----- +            + ----- +
  xStart               pxEnd

The code block which traverses the list of free blocks to calculate heap
stats used a do..while loop that moved past the end marker when the heap
had no free block resulting in a NULL pointer dereference. This commit
changes the do..while loop to while loop thereby ensuring that we never
move past the end marker.

This was reported here - https://github.com/FreeRTOS/FreeRTOS-Kernel/issues/534

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
portable/MemMang/heap_4.c
portable/MemMang/heap_5.c