mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed corruption check during free
This commit is contained in:
parent
596dd2401d
commit
3b662a9d74
1 changed files with 248 additions and 248 deletions
|
@ -599,7 +599,7 @@ void* BfObjectAllocate(intptr size, bf::System::Type* objType)
|
|||
result = BF_do_malloc_pages(ThreadCache::GetCache(), totalSize);
|
||||
}
|
||||
|
||||
BF_ASSERT(totalSize - size <= kPageSize);
|
||||
BF_ASSERT(totalSize - (size + 4) <= kPageSize);
|
||||
*(uint16*)((uint8*)result + size) = 0xBFBF;
|
||||
*(uint16*)((uint8*)result + totalSize - 2) = totalSize - size;
|
||||
|
||||
|
@ -975,7 +975,7 @@ void BFGC::ObjectDeleteRequested(bf::System::Object* obj)
|
|||
|
||||
int sizeOffset = *(uint16*)((uint8*)obj + allocSize - 2);
|
||||
int requestedSize = allocSize - sizeOffset;
|
||||
if ((sizeOffset < 4) || (sizeOffset >= allocSize) || (sizeOffset > kPageSize) ||
|
||||
if ((sizeOffset < 4) || (sizeOffset >= allocSize) || (sizeOffset >= kPageSize + 4) ||
|
||||
(*(uint16*)((uint8*)obj + requestedSize) != 0xBFBF))
|
||||
{
|
||||
Beefy::String err = Beefy::StrFormat("Memory deallocation detected write-past-end error in %d-byte object allocation at 0x%@", requestedSize, obj);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue