diff --git a/netwerk/cache/src/nsDiskCacheDevice.cpp b/netwerk/cache/src/nsDiskCacheDevice.cpp index 8228efd496e1..076c5630bf2e 100644 --- a/netwerk/cache/src/nsDiskCacheDevice.cpp +++ b/netwerk/cache/src/nsDiskCacheDevice.cpp @@ -554,7 +554,7 @@ NS_IMETHODIMP nsDiskCacheEntryInfo::GetDataSize(PRUint32 *aDataSize) static nsCOMPtr gFileTransportService; nsDiskCacheDevice::nsDiskCacheDevice() - : mCacheCapacity(0), mCacheSize(0) + : mCacheCapacity(0), mCacheSize(0), mInitialized(PR_FALSE) { } @@ -562,6 +562,7 @@ nsDiskCacheDevice::~nsDiskCacheDevice() { removeObservers(this); + if (mInitialized) { #if 1 // XXX implement poor man's eviction strategy right here, // keep deleting cache entries from oldest to newest, until @@ -571,7 +572,7 @@ nsDiskCacheDevice::~nsDiskCacheDevice() // XXX write out persistent information about the cache. writeCacheInfo(); - + } // XXX release the reference to the cached file transport service. gFileTransportService = nsnull; } @@ -598,6 +599,7 @@ nsDiskCacheDevice::Init() scanDiskCacheEntries(getter_AddRefs(entries)); } + mInitialized = PR_TRUE; return NS_OK; } diff --git a/netwerk/cache/src/nsDiskCacheDevice.h b/netwerk/cache/src/nsDiskCacheDevice.h index 29642ecef39f..6bc76de61177 100644 --- a/netwerk/cache/src/nsDiskCacheDevice.h +++ b/netwerk/cache/src/nsDiskCacheDevice.h @@ -93,6 +93,7 @@ private: nsDiskCacheEntryHashTable mBoundEntries; PRUint32 mCacheCapacity; PRUint32 mCacheSize; + PRBool mInitialized; }; #endif // _nsDiskCacheDevice_h_ diff --git a/netwerk/cache/src/nsDiskCacheEntry.cpp b/netwerk/cache/src/nsDiskCacheEntry.cpp index d262c4935386..22f922861541 100644 --- a/netwerk/cache/src/nsDiskCacheEntry.cpp +++ b/netwerk/cache/src/nsDiskCacheEntry.cpp @@ -42,14 +42,15 @@ PLDHashTableOps nsDiskCacheEntryHashTable::ops = }; nsDiskCacheEntryHashTable::nsDiskCacheEntryHashTable() - : initialized(0) + : initialized(PR_FALSE) { } nsDiskCacheEntryHashTable::~nsDiskCacheEntryHashTable() { - PL_DHashTableFinish(&table); + if (initialized) + PL_DHashTableFinish(&table); }