Skip to content

Commit

Permalink
Bug 1276724 - Make two url-classifier allocations fallible. r=gcp.
Browse files Browse the repository at this point in the history
This addresses two crashes in the top #75 on 47.0.1.
  • Loading branch information
nnethercote committed Jul 29, 2016
1 parent 9f39a59 commit b89b0e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion toolkit/components/url-classifier/HashStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,9 @@ HashStore::WriteAddPrefixes(nsIOutputStream* aOut)
{
nsTArray<uint32_t> chunks;
uint32_t count = mAddPrefixes.Length();
chunks.SetCapacity(count);
if (!chunks.SetCapacity(count, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}

for (uint32_t i = 0; i < count; i++) {
chunks.AppendElement(mAddPrefixes[i].Chunk());
Expand Down
4 changes: 3 additions & 1 deletion toolkit/components/url-classifier/LookupCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,9 @@ LookupCache::ConstructPrefixSet(AddPrefixArray& aAddPrefixes)
Telemetry::AutoTimer<Telemetry::URLCLASSIFIER_PS_CONSTRUCT_TIME> timer;

nsTArray<uint32_t> array;
array.SetCapacity(aAddPrefixes.Length());
if (!array.SetCapacity(aAddPrefixes.Length(), fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}

for (uint32_t i = 0; i < aAddPrefixes.Length(); i++) {
array.AppendElement(aAddPrefixes[i].PrefixHash().ToUint32());
Expand Down

0 comments on commit b89b0e1

Please sign in to comment.