1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Fixed leak checking for >1 stack trace depth

This commit is contained in:
Brian Fiete 2020-07-11 16:22:37 -07:00
parent a1c8d60d4b
commit 5cb6570e14

View file

@ -385,26 +385,26 @@ bf::System::Object* Internal::Dbg_ObjectAlloc(bf::System::ClassVData* classVData
// through. // through.
intptr dbgAllocInfo; intptr dbgAllocInfo;
auto classVDataVal = (intptr)classVData | (intptr)BfObjectFlag_Allocated; auto classVDataVal = (intptr)classVData | (intptr)BfObjectFlag_Allocated;
result->mClassVData = classVDataVal;
if (maxStackTraceDepth <= 1) if (maxStackTraceDepth <= 1)
dbgAllocInfo = (intptr)BF_RETURN_ADDRESS; dbgAllocInfo = (intptr)BF_RETURN_ADDRESS;
else else
{ {
if (largeAllocInfo) if (largeAllocInfo)
{ {
result->mClassVData |= (intptr)BfObjectFlag_AllocInfo; classVDataVal |= (intptr)BfObjectFlag_AllocInfo;
dbgAllocInfo = size; dbgAllocInfo = size;
*(intptr*)((uint8*)result + size) = capturedTraceCount; *(intptr*)((uint8*)result + size) = capturedTraceCount;
memcpy((uint8*)result + size + sizeof(intptr), stackTrace, capturedTraceCount * sizeof(intptr)); memcpy((uint8*)result + size + sizeof(intptr), stackTrace, capturedTraceCount * sizeof(intptr));
} }
else else
{ {
result->mClassVData |= (intptr)BfObjectFlag_AllocInfo_Short; classVDataVal |= (intptr)BfObjectFlag_AllocInfo_Short;
dbgAllocInfo = (size << 16) | capturedTraceCount; dbgAllocInfo = (size << 16) | capturedTraceCount;
memcpy((uint8*)result + size, stackTrace, capturedTraceCount * sizeof(intptr)); memcpy((uint8*)result + size, stackTrace, capturedTraceCount * sizeof(intptr));
} }
} }
result->mClassVData = classVDataVal;
BF_FULL_MEMORY_FENCE(); // Since we depend on mDbAllocInfo to determine if we are allocated, we need to set this last after we're set up BF_FULL_MEMORY_FENCE(); // Since we depend on mDbAllocInfo to determine if we are allocated, we need to set this last after we're set up
result->mDbgAllocInfo = dbgAllocInfo; result->mDbgAllocInfo = dbgAllocInfo;
BF_FULL_MEMORY_FENCE(); BF_FULL_MEMORY_FENCE();