git: 9front

Download patch

ref: 460b602d35f7a11631e9c3e1913d33615c1e0cda
parent: 2e25269da3910a7af00603283775bb2b4086868d
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Oct 20 15:52:54 EDT 2018

kernel: fix allocb for BLOCKALIGN*2 >= Hdrspc

--- a/sys/src/9/port/allocb.c
+++ b/sys/src/9/port/allocb.c
@@ -19,7 +19,8 @@
 	uintptr addr;
 
 	size += Tlrspc;
-	if((b = mallocz(sizeof(Block)+size+Hdrspc, 0)) == nil)
+	size = ROUND(size, BLOCKALIGN);
+	if((b = mallocz(sizeof(Block)+BLOCKALIGN+Hdrspc+size, 0)) == nil)
 		return nil;
 
 	b->next = nil;
@@ -38,11 +39,8 @@
 	addr &= ~(BLOCKALIGN-1);
 	b->lim = (uchar*)addr;
 
-	/* leave sluff at beginning for added headers */
-	b->rp = b->lim - ROUND(size, BLOCKALIGN);
-	if(b->rp < b->base)
-		panic("_allocb");
-	b->wp = b->rp;
+	/* leave room at beginning for added headers */
+	b->wp = b->rp = b->lim - size;
 
 	return b;
 }
--