summaryrefslogtreecommitdiff
path: root/sys/src/libc/port
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-04-08 21:04:10 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2015-04-08 21:04:10 +0200
commitca4e12839aa7234104c5d455046c8ea20af64dec (patch)
tree0a3ae1e6aee25db0692b4fa15ad4bc5a99b0d651 /sys/src/libc/port
parentadfb8dff26976e201208f3f8ddc3cdc1d34cd8cb (diff)
pool: avoid triggering assert(b->magic != FREE_MAGIC) in blocksetsize() for mallocalignl()
when we trim the front of a block with freefromfront(), the block magic of the back was not initialized which could sometimes trigger the assert in blocksetsize() to fail. fix is to just move the initialization of the magic field before the blocksetsize() call. the second b->magic = UNALLOC_MAGIC isnt really required but just done for consistency with the trim() code above.
Diffstat (limited to 'sys/src/libc/port')
-rw-r--r--sys/src/libc/port/pool.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/src/libc/port/pool.c b/sys/src/libc/port/pool.c
index 201215aa9..3dad7f74f 100644
--- a/sys/src/libc/port/pool.c
+++ b/sys/src/libc/port/pool.c
@@ -520,10 +520,10 @@ freefromfront(Pool *p, Alloc *b, ulong skip)
skip = skip&~(p->quantum-1);
if(skip >= 0x1000 || (skip >= b->size>>2 && skip >= MINBLOCKSIZE && skip >= p->minblock)){
bb = (Alloc*)((uchar*)b+skip);
- blocksetsize(bb, b->size-skip);
bb->magic = UNALLOC_MAGIC;
- blocksetsize(b, skip);
+ blocksetsize(bb, b->size-skip);
b->magic = UNALLOC_MAGIC;
+ blocksetsize(b, skip);
pooladd(p, b);
return bb;
}