X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FLibraries%2Flibc.so_src%2Fheap.c;h=1c0c7acfa4348b984da7d794b9fbf59e54086964;hb=16452b14885a8046adef7ec4ca9b9083a9ba2818;hp=779b0048d44938a80dbae3c058e93db9e85ac064;hpb=8dcc3e209d0d728565a18c8dca2b0ba220b74a6f;p=tpg%2Facess2.git diff --git a/Usermode/Libraries/libc.so_src/heap.c b/Usermode/Libraries/libc.so_src/heap.c index 779b0048..1c0c7acf 100644 --- a/Usermode/Libraries/libc.so_src/heap.c +++ b/Usermode/Libraries/libc.so_src/heap.c @@ -94,13 +94,16 @@ EXPORT void *malloc(size_t bytes) //Corrupt Heap Heap_Dump(); _SysDebug("malloc: Corrupt Heap\n"); + exit(128); return NULL; } curBlock = (heap_head*)((uintptr_t)curBlock + curBlock->size); } if((uintptr_t)curBlock < (uintptr_t)_heap_start) { + Heap_Dump(); _SysDebug("malloc: Heap underrun for some reason\n"); + exit(128); return NULL; } @@ -185,7 +188,7 @@ EXPORT void free(void *mem) DEBUGS("free(%p) : 0x%x bytes", mem, head->size); //Unify Right - if((intptr_t)head + head->size < (intptr_t)_heap_end) + if((uintptr_t)head + head->size < (uintptr_t)_heap_end) { heap_head *nextHead = (heap_head*)((intptr_t)head + head->size); if(nextHead->magic == MAGIC_FREE) { //Is the next block free @@ -194,7 +197,7 @@ EXPORT void free(void *mem) } } //Unify Left - if((intptr_t)head - sizeof(heap_foot) > (intptr_t)_heap_start) + if((uintptr_t)head - sizeof(heap_foot) > (uintptr_t)_heap_start) { heap_head *prevHead; heap_foot *prevFoot = (heap_foot *)((intptr_t)head - sizeof(heap_foot)); @@ -448,7 +451,7 @@ LOCAL uint brk(uintptr_t newpos) void Heap_Dump(void) { heap_head *cur = _heap_start; - while( cur < _heap_end ) + while( cur < (heap_head*)_heap_end ) { switch( cur->magic ) {