From 589e691ba8503dd247aaeab76c1113f87c2ff980 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 7 Nov 2024 15:34:39 -0800 Subject: Fixed long standing double-free bug in the cache. I guess we don't delete stuff very often. --- src/unstable/cachebase.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/unstable/cachebase.h') diff --git a/src/unstable/cachebase.h b/src/unstable/cachebase.h index ec73ede..9ac1b8c 100644 --- a/src/unstable/cachebase.h +++ b/src/unstable/cachebase.h @@ -32,11 +32,15 @@ namespace Bu bDeleted( false ), pObject( pObject ) { + Bu::println("CacheEntry::CacheEntry: registering pObject (0x%1)"). + arg( reinterpret_cast(pObject), Bu::Fmt::hex() ); } virtual ~CacheEntry() { mEntry.lock(); + Bu::println("CacheEntry::~CacheEntry: deleting pObject (0x%1)"). + arg( reinterpret_cast(pObject), Bu::Fmt::hex() ); delete pObject; mEntry.unlock(); } @@ -497,7 +501,7 @@ namespace Bu if( pEnt->iRefCount == 0 ) { pEnt->mEntry.unlock(); - delete pEnt->pObject; + //delete pEnt->pObject; delete pEnt; } else @@ -529,7 +533,7 @@ namespace Bu pEnt->mEntry.unlock(); throw Bu::ExceptionBase( Bu::String("Cache entry %1 cannot be erased, there are %2 active references.").arg( key ).arg( iCount ).end().getStr() ); } - delete pEnt->pObject; + //delete pEnt->pObject; delete pEnt; hCacheEntry.erase( key ); } @@ -559,7 +563,7 @@ namespace Bu { if( pEnt->isReadyForCleanup() ) { - delete pEnt->pObject; + //delete pEnt->pObject; delete pEnt; } } -- cgit v1.2.3