[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[win-pv-devel] [PATCH 3/3] Fix austere allocator when small heap list head is NULL



Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xencrsh/austere.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/xencrsh/austere.c b/src/xencrsh/austere.c
index 6851475..e00a329 100644
--- a/src/xencrsh/austere.c
+++ b/src/xencrsh/austere.c
@@ -130,7 +130,7 @@ retry:
 
     Res = (PVOID)(AustereHeap.BigHeapStart + i * PAGE_SIZE);
     if (AustereHeap.HeapBlockSizes[i] != (NumPages | FREE_CHUNK)) {
-        if (i + NumPages <= AUSTERE_HEAP_PAGES)
+        if (i + NumPages != AUSTERE_HEAP_PAGES)
             AustereHeap.HeapBlockSizes[i + NumPages] = 
AustereHeap.HeapBlockSizes[i] - NumPages;
     }
     AustereHeap.HeapBlockSizes[i] = NumPages;
@@ -262,7 +262,8 @@ __AllocSmall(
             SubHeap->Next->Prev = SubHeap->Prev;
         SubHeap->Prev = NULL;
         SubHeap->Next = AustereHeap.HeadSubHeap;
-        AustereHeap.HeadSubHeap->Prev = SubHeap;
+        if (AustereHeap.HeadSubHeap)
+            AustereHeap.HeadSubHeap->Prev = SubHeap;
         AustereHeap.HeadSubHeap = SubHeap;
     }
     return Res;
@@ -328,7 +329,8 @@ __FreeSmall(
             SubHeap->Next->Prev = SubHeap->Prev;
         SubHeap->Prev = NULL;
         SubHeap->Next = AustereHeap.HeadSubHeap;
-        AustereHeap.HeadSubHeap->Prev = SubHeap;
+        if (AustereHeap.HeadSubHeap)
+            AustereHeap.HeadSubHeap->Prev = SubHeap;
         AustereHeap.HeadSubHeap = SubHeap;
     }
 }
@@ -379,6 +381,9 @@ __AustereAllocate(
 {
     PVOID   Res;
 
+    if (Size < sizeof(PVOID))
+        Size = sizeof(PVOID);
+
     if (Size > AUSTERE_MAX_ALLOC_SIZE) {
         LogError("%s failing alloc of %d bytes (%d maximum)\n", Caller, Size, 
AUSTERE_MAX_ALLOC_SIZE);
         return NULL;
-- 
1.9.4.msysgit.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.