From 1cf2b35529b40d82ab1a6b33cb00d4f29434c225 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Tue, 21 Nov 2017 00:12:31 -0700 Subject: [PATCH] Memory: Fix #705: don't use pool object after invoking destructor. --- glslang/MachineIndependent/PoolAlloc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/glslang/MachineIndependent/PoolAlloc.cpp b/glslang/MachineIndependent/PoolAlloc.cpp index c42057c2..7d07a399 100644 --- a/glslang/MachineIndependent/PoolAlloc.cpp +++ b/glslang/MachineIndependent/PoolAlloc.cpp @@ -201,15 +201,15 @@ void TPoolAllocator::pop() currentPageOffset = stack.back().offset; while (inUseList != page) { - // invoke destructor to free allocation list - inUseList->~tHeader(); - tHeader* nextInUse = inUseList->nextPage; - if (inUseList->pageCount > 1) + if (inUseList->pageCount > 1) { + inUseList->~tHeader(); // currently, just a debug allocation checker delete [] reinterpret_cast(inUseList); - else { + } else { inUseList->nextPage = freeList; freeList = inUseList; + // inUseList->~tHeader(); TODO: this should probably call the allocation checker, but not the destructor + // ...if the destructor actually overwrites nextPage, that would effect freeList->nextPage } inUseList = nextInUse; }