[PATCH 2/4] cpukit: more robust error detection in allocate

Alexander Krutwig alexander.krutwig at embedded-brains.de
Thu Jun 16 13:48:45 UTC 2016


---
 cpukit/score/src/heapallocate.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/cpukit/score/src/heapallocate.c b/cpukit/score/src/heapallocate.c
index a76ac04..77ed582 100644
--- a/cpukit/score/src/heapallocate.c
+++ b/cpukit/score/src/heapallocate.c
@@ -43,9 +43,14 @@
       uintptr_t count = 0;
 
       for ( count = 0; count < blocks_to_free_count; ++count ) {
-        Heap_Block *next_block_to_free =
-          block_to_free->Protection_begin.next_delayed_free_block;
+        Heap_Block *next_block_to_free;
+
+        if ( !_Heap_Is_block_in_heap( heap, block_to_free ) ) {
+          _Heap_Protection_block_error( heap, block_to_free );
+        }
 
+        next_block_to_free =
+          block_to_free->Protection_begin.next_delayed_free_block;
         block_to_free->Protection_begin.next_delayed_free_block =
           HEAP_PROTECTION_OBOLUS;
 
-- 
1.8.4.5




More information about the devel mailing list