mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1606102 - Don't use putNew in StartupCache::LoadArchive r=froydnj
We can't guarantee uniqueness of the keys here because the file might be corrupt. So we should check if the key exists and if it does, bail out. Differential Revision: https://phabricator.services.mozilla.com/D58387 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
f6604cf751
commit
87af0f0874
@ -319,8 +319,17 @@ Result<Ok, nsresult> StartupCache::LoadArchive() {
|
||||
}
|
||||
currentOffset += compressedSize;
|
||||
|
||||
if (!mTable.putNew(key, StartupCacheEntry(offset, compressedSize,
|
||||
uncompressedSize))) {
|
||||
// We could use mTable.putNew if we knew the file we're loading weren't
|
||||
// corrupt. However, we don't know that, so check if the key already
|
||||
// exists. If it does, we know the file must be corrupt.
|
||||
decltype(mTable)::AddPtr p = mTable.lookupForAdd(key);
|
||||
if (p) {
|
||||
return Err(NS_ERROR_UNEXPECTED);
|
||||
}
|
||||
|
||||
if (!mTable.add(
|
||||
p, key,
|
||||
StartupCacheEntry(offset, compressedSize, uncompressedSize))) {
|
||||
return Err(NS_ERROR_UNEXPECTED);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user