Coverity: Reverse INULL: CID 202
authorNelson Ferreira <nelson.ferreira@ieee.org>
Fri, 20 Jan 2012 03:26:32 +0000 (22:26 -0500)
committerNelson Ferreira <nelson.ferreira@ieee.org>
Fri, 20 Jan 2012 03:26:32 +0000 (22:26 -0500)
* src/mem/ralloc.c (update_heap_bloc_correspondence): Be extra
safe and do "abort" on violation of stated (in comment) invariant.

Signed-off-by: Nelson Ferreira <nelson.ferreira@ieee.org>
src/mem/ralloc.c

index c78bf2b..bd55ca3 100644 (file)
@@ -559,9 +559,17 @@ static void update_heap_bloc_correspondence(bloc_ptr bloc, heap_ptr heap)
                        heap = heap->next;
                        /* We know HEAP is not null now,
                           because there has to be space for bloc B.  */
-                       heap->first_bloc = NIL_BLOC;
-                       heap->last_bloc = NIL_BLOC;
-                       heap->free = heap->bloc_start;
+                       if ( heap ) {
+                               /* But we still tested it... */
+                               heap->first_bloc = NIL_BLOC;
+                               heap->last_bloc = NIL_BLOC;
+                               heap->free = heap->bloc_start;
+                       } else {
+                               /* ... and now abort if proven
+                                  otherwise... 
+                               */
+                               abort();
+                       }
                }
                if (heap == NULL)
                        break;