Skip to content

Commit 90b39db

Browse files
author
devsh
committed
final fix
1 parent 01b9ef5 commit 90b39db

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

include/nbl/asset/material_compiler3/CNodePool.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@ class CNodePool : public core::IReferenceCounted
172172
{
173173
T* ptr = deref<T>(h);
174174
const uint32_t size = ptr->getSize();
175-
ptr->~INode(); // can't use `std::destroy_at<T>(ptr);` because of destructor being non-public
175+
static_cast<INode*>(ptr)->~INode(); // can't use `std::destroy_at<T>(ptr);` because of destructor being non-public
176176
// wipe v-table to mark as dead (so `~CNodePool` doesn't run destructor twice)
177177
const void* nullVTable = nullptr;
178-
assert(memcmp(ptr,nullVTable,sizeof(nullVTable))!=0); // double free
178+
assert(memcmp(ptr,&nullVTable,sizeof(nullVTable))!=0); // double free
179179
memset(static_cast<INode*>(ptr),0,sizeof(nullVTable));
180-
free(h,size);
180+
free(h.untyped,size);
181181
}
182182

183183
inline CNodePool(const uint8_t _chunkSizeLog2, const uint8_t _maxNodeAlignLog2, refctd_pmr_t&& _pmr) :
@@ -196,7 +196,7 @@ class CNodePool : public core::IReferenceCounted
196196
for (auto handleOff=chunk.getAllocator().get_total_size(); handleOff<chunkSize; handleOff+=sizeof(Handle))
197197
{
198198
const auto pHandle = reinterpret_cast<const Handle*>(chunk.m_data+handleOff);
199-
if (auto* node=deref<INode>(*pHandle); *reinterpret_cast<const void* const*>(node))
199+
if (auto* node=deref<INode>(*pHandle); node)
200200
node->~INode(); // can't use `std::destroy_at<T>(ptr);` because of destructor being non-public
201201
}
202202
m_pmr->deallocate(chunk.m_data,chunkSize,chunkAlign);

0 commit comments

Comments
 (0)