aboutsummaryrefslogtreecommitdiff
path: root/src/unstable
diff options
context:
space:
mode:
authorMike Buland <mbuland@penny-arcade.com>2024-11-07 15:34:39 -0800
committerMike Buland <mbuland@penny-arcade.com>2024-11-07 15:34:39 -0800
commit589e691ba8503dd247aaeab76c1113f87c2ff980 (patch)
tree5d4132085ec8a277c2dd5fbef19cf38ff9e3cb76 /src/unstable
parent6c066b6bbd4a44ae7c5874abf6bd3a3e04f76b88 (diff)
downloadlibbu++-589e691ba8503dd247aaeab76c1113f87c2ff980.tar.gz
libbu++-589e691ba8503dd247aaeab76c1113f87c2ff980.tar.bz2
libbu++-589e691ba8503dd247aaeab76c1113f87c2ff980.tar.xz
libbu++-589e691ba8503dd247aaeab76c1113f87c2ff980.zip
Fixed long standing double-free bug in the cache.
I guess we don't delete stuff very often.
Diffstat (limited to '')
-rw-r--r--src/unstable/cachebase.h10
1 files changed, 7 insertions, 3 deletions
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
32 bDeleted( false ), 32 bDeleted( false ),
33 pObject( pObject ) 33 pObject( pObject )
34 { 34 {
35 Bu::println("CacheEntry::CacheEntry: registering pObject (0x%1)").
36 arg( reinterpret_cast<ptrdiff_t>(pObject), Bu::Fmt::hex() );
35 } 37 }
36 38
37 virtual ~CacheEntry() 39 virtual ~CacheEntry()
38 { 40 {
39 mEntry.lock(); 41 mEntry.lock();
42 Bu::println("CacheEntry::~CacheEntry: deleting pObject (0x%1)").
43 arg( reinterpret_cast<ptrdiff_t>(pObject), Bu::Fmt::hex() );
40 delete pObject; 44 delete pObject;
41 mEntry.unlock(); 45 mEntry.unlock();
42 } 46 }
@@ -497,7 +501,7 @@ namespace Bu
497 if( pEnt->iRefCount == 0 ) 501 if( pEnt->iRefCount == 0 )
498 { 502 {
499 pEnt->mEntry.unlock(); 503 pEnt->mEntry.unlock();
500 delete pEnt->pObject; 504 //delete pEnt->pObject;
501 delete pEnt; 505 delete pEnt;
502 } 506 }
503 else 507 else
@@ -529,7 +533,7 @@ namespace Bu
529 pEnt->mEntry.unlock(); 533 pEnt->mEntry.unlock();
530 throw Bu::ExceptionBase( Bu::String("Cache entry %1 cannot be erased, there are %2 active references.").arg( key ).arg( iCount ).end().getStr() ); 534 throw Bu::ExceptionBase( Bu::String("Cache entry %1 cannot be erased, there are %2 active references.").arg( key ).arg( iCount ).end().getStr() );
531 } 535 }
532 delete pEnt->pObject; 536 //delete pEnt->pObject;
533 delete pEnt; 537 delete pEnt;
534 hCacheEntry.erase( key ); 538 hCacheEntry.erase( key );
535 } 539 }
@@ -559,7 +563,7 @@ namespace Bu
559 { 563 {
560 if( pEnt->isReadyForCleanup() ) 564 if( pEnt->isReadyForCleanup() )
561 { 565 {
562 delete pEnt->pObject; 566 //delete pEnt->pObject;
563 delete pEnt; 567 delete pEnt;
564 } 568 }
565 } 569 }