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.
This commit is contained in:
parent
adfb8dff26
commit
ca4e12839a
1 changed files with 2 additions and 2 deletions
|
@ -520,10 +520,10 @@ freefromfront(Pool *p, Alloc *b, ulong skip)
|
||||||
skip = skip&~(p->quantum-1);
|
skip = skip&~(p->quantum-1);
|
||||||
if(skip >= 0x1000 || (skip >= b->size>>2 && skip >= MINBLOCKSIZE && skip >= p->minblock)){
|
if(skip >= 0x1000 || (skip >= b->size>>2 && skip >= MINBLOCKSIZE && skip >= p->minblock)){
|
||||||
bb = (Alloc*)((uchar*)b+skip);
|
bb = (Alloc*)((uchar*)b+skip);
|
||||||
blocksetsize(bb, b->size-skip);
|
|
||||||
bb->magic = UNALLOC_MAGIC;
|
bb->magic = UNALLOC_MAGIC;
|
||||||
blocksetsize(b, skip);
|
blocksetsize(bb, b->size-skip);
|
||||||
b->magic = UNALLOC_MAGIC;
|
b->magic = UNALLOC_MAGIC;
|
||||||
|
blocksetsize(b, skip);
|
||||||
pooladd(p, b);
|
pooladd(p, b);
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue