mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
Fix bug 82370, leak in disk cache. r=dbaron, sr=darin, a=asa.
This commit is contained in:
parent
c626d6e35a
commit
d169ac5e97
8
netwerk/cache/src/nsDiskCacheDevice.cpp
vendored
8
netwerk/cache/src/nsDiskCacheDevice.cpp
vendored
@ -344,7 +344,7 @@ nsDiskCacheEvictor::VisitRecord(nsDiskCacheRecord * mapRecord)
|
||||
exit:
|
||||
|
||||
delete clientID;
|
||||
delete diskEntry;
|
||||
delete [] (char *)diskEntry;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -620,7 +620,7 @@ nsDiskCacheDevice::FindEntry(nsCString * key)
|
||||
if (nsCRT::strcmp(diskEntry->mKeyStart, key->get()) == 0) {
|
||||
entry = diskEntry->CreateCacheEntry(this);
|
||||
}
|
||||
delete diskEntry;
|
||||
delete [] (char *)diskEntry;
|
||||
|
||||
// If we had a hash collision or CreateCacheEntry failed, return nsnull
|
||||
if (!entry) return nsnull;
|
||||
@ -895,7 +895,7 @@ public:
|
||||
nsresult rv = mCacheMap->ReadDiskCacheEntry(mapRecord, &diskEntry);
|
||||
if (NS_FAILED(rv)) {
|
||||
mResult = rv;
|
||||
return kStopVisitingRecords;
|
||||
return kVisitNextRecord;
|
||||
}
|
||||
|
||||
// create nsICacheEntryInfo
|
||||
@ -908,7 +908,7 @@ public:
|
||||
|
||||
PRBool keepGoing;
|
||||
rv = mVisitor->VisitEntry(DISK_CACHE_DEVICE_ID, entryInfo, &keepGoing);
|
||||
delete diskEntry;
|
||||
delete [] (char *)diskEntry;
|
||||
return keepGoing ? kVisitNextRecord : kStopVisitingRecords;
|
||||
}
|
||||
|
||||
|
8
netwerk/cache/src/nsDiskCacheEntry.cpp
vendored
8
netwerk/cache/src/nsDiskCacheEntry.cpp
vendored
@ -128,7 +128,7 @@ CreateDiskCacheEntry(nsDiskCacheBinding * binding)
|
||||
PRUint32 metaSize = 0;
|
||||
nsresult rv = entry->FlattenMetaData(&metaData, &metaSize);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete diskEntry;
|
||||
delete [] (char *)diskEntry;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
@ -137,6 +137,12 @@ CreateDiskCacheEntry(nsDiskCacheBinding * binding)
|
||||
nsCRT::memcpy(&diskEntry->mKeyStart[keySize], metaData, metaSize);
|
||||
|
||||
delete metaData;
|
||||
|
||||
pad -= diskEntry->Size();
|
||||
NS_ASSERTION(pad >= 0, "under allocated buffer for diskEntry.");
|
||||
if (pad > 0)
|
||||
nsCRT::zero(&diskEntry->mKeyStart[keySize+metaSize], pad);
|
||||
|
||||
return diskEntry;
|
||||
}
|
||||
|
||||
|
8
netwerk/cache/src/nsDiskCacheMap.cpp
vendored
8
netwerk/cache/src/nsDiskCacheMap.cpp
vendored
@ -562,6 +562,8 @@ nsDiskCacheMap::ReadDiskCacheEntry(nsDiskCacheRecord * record, nsDiskCacheEntry
|
||||
PRFileDesc * fd = nsnull;
|
||||
*result = nsnull;
|
||||
|
||||
if (!record->MetaLocationInitialized()) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
if (metaFile == 0) { // entry/metadata stored in separate file
|
||||
// open and read the file
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
@ -614,7 +616,7 @@ nsDiskCacheMap::ReadDiskCacheEntry(nsDiskCacheRecord * record, nsDiskCacheEntry
|
||||
exit:
|
||||
// XXX auto ptr would be nice
|
||||
if (fd) (void) PR_Close(fd);
|
||||
delete diskEntry;
|
||||
delete [] (char *)diskEntry;
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -657,7 +659,7 @@ nsDiskCacheMap::WriteDiskCacheEntry(nsDiskCacheBinding * binding)
|
||||
"generations out of sync");
|
||||
} else {
|
||||
rv = DeleteStorage(&binding->mRecord, nsDiskCache::kMetaData);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv)) goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -719,7 +721,7 @@ nsDiskCacheMap::WriteDiskCacheEntry(nsDiskCacheBinding * binding)
|
||||
}
|
||||
|
||||
exit:
|
||||
|
||||
delete [] (char *)diskEntry;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user