зеркало из https://github.com/mozilla/pjs.git
Fixing bugs in nsZipReaderCache. Bug 18433
This commit is contained in:
Родитель
b2568c5b2f
Коммит
149637ee28
|
@ -153,7 +153,8 @@ nsJAR::nsJAR(): mManifestData(nsnull, nsnull, DeleteManifestEntry, nsnull, 10),
|
||||||
}
|
}
|
||||||
|
|
||||||
nsJAR::~nsJAR()
|
nsJAR::~nsJAR()
|
||||||
{
|
{
|
||||||
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsJAR, nsIZipReader);
|
NS_IMPL_THREADSAFE_ISUPPORTS1(nsJAR, nsIZipReader);
|
||||||
|
@ -1146,16 +1147,16 @@ nsZipReaderCache::~nsZipReaderCache()
|
||||||
NS_METHOD
|
NS_METHOD
|
||||||
nsZipReaderCache::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
nsZipReaderCache::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||||
{
|
{
|
||||||
if (aOuter)
|
if (aOuter)
|
||||||
return NS_ERROR_NO_AGGREGATION;
|
return NS_ERROR_NO_AGGREGATION;
|
||||||
|
|
||||||
nsZipReaderCache* cache = new nsZipReaderCache();
|
nsZipReaderCache* cache = new nsZipReaderCache();
|
||||||
if (cache == nsnull)
|
if (cache == nsnull)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
NS_ADDREF(cache);
|
NS_ADDREF(cache);
|
||||||
nsresult rv = cache->QueryInterface(aIID, aResult);
|
nsresult rv = cache->QueryInterface(aIID, aResult);
|
||||||
NS_RELEASE(cache);
|
NS_RELEASE(cache);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -1172,14 +1173,14 @@ nsZipReaderCache::GetZip(nsIFile* zipFile, nsIZipReader* *result)
|
||||||
nsZipCacheEntry* entry = (nsZipCacheEntry*)mZips.Get(&key);
|
nsZipCacheEntry* entry = (nsZipCacheEntry*)mZips.Get(&key);
|
||||||
if (entry) {
|
if (entry) {
|
||||||
*result = entry->mZip;
|
*result = entry->mZip;
|
||||||
NS_ADDREF(*result);
|
NS_ADDREF(*result); // addref for the caller
|
||||||
if (entry->mUseCount++ == 0) {
|
if (entry->mUseCount++ == 0) {
|
||||||
// remove from free list
|
// remove from free list
|
||||||
nsZipCacheEntry** entryPtr = &mFreeList;
|
nsZipCacheEntry** entryPtr = &mFreeList;
|
||||||
NS_ASSERTION(*entryPtr, "null free list");
|
NS_ASSERTION(*entryPtr, "null free list");
|
||||||
while ((*entryPtr)->mNextOlder != nsnull) {
|
while (*entryPtr != nsnull) {
|
||||||
if ((*entryPtr)->mNextOlder == entry) {
|
if (*entryPtr == entry) {
|
||||||
(*entryPtr)->mNextOlder = entry->mNextOlder;
|
*entryPtr = entry->mNextOlder;
|
||||||
entry->mNextOlder = nsnull;
|
entry->mNextOlder = nsnull;
|
||||||
--mFreeCount;
|
--mFreeCount;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -1208,7 +1209,7 @@ nsZipReaderCache::GetZip(nsIFile* zipFile, nsIZipReader* *result)
|
||||||
entry->mUseCount++;
|
entry->mUseCount++;
|
||||||
(void)mZips.Put(&key, entry);
|
(void)mZips.Put(&key, entry);
|
||||||
*result = zip;
|
*result = zip;
|
||||||
NS_ADDREF(*result);
|
NS_ADDREF(*result); // addref for the caller
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1252,10 +1253,11 @@ nsZipReaderCache::ReleaseZip(nsIZipReader* zip)
|
||||||
nsZipCacheEntry* elt = (nsZipCacheEntry*)mZips.Remove(&key);
|
nsZipCacheEntry* elt = (nsZipCacheEntry*)mZips.Remove(&key);
|
||||||
NS_ASSERTION(elt == entry, "Remove failed");
|
NS_ASSERTION(elt == entry, "Remove failed");
|
||||||
--mFreeCount;
|
--mFreeCount;
|
||||||
|
delete oldest; // release zip for good
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_RELEASE(zip);
|
// NS_RELEASE(zip); // release for the caller
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -328,6 +328,7 @@ PRInt32 nsZipArchive::CloseArchive()
|
||||||
// close the file if open
|
// close the file if open
|
||||||
if ( mFd != 0 ) {
|
if ( mFd != 0 ) {
|
||||||
PR_Close(mFd);
|
PR_Close(mFd);
|
||||||
|
mFd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete nsZipItems in table
|
// delete nsZipItems in table
|
||||||
|
|
Загрузка…
Ссылка в новой задаче