Bug 1276724 - Make two url-classifier allocations fallible. r=gcp.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 29 Jul 2016 19:34:20 +1000
changeset 349362 19c9fa346278d7fabd7a4dfebd4cee0c263ec551
parent 349361 64fa2d708a10b158a57599016bf9f4a8f92b3024
child 349363 acf56d9e08c5e44278e62c28ad1ac8c198718d53
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgcp
bugs1276724
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1276724 - Make two url-classifier allocations fallible. r=gcp. This addresses two crashes in the top #75 on 47.0.1.
toolkit/components/url-classifier/HashStore.cpp
toolkit/components/url-classifier/LookupCache.cpp
--- a/toolkit/components/url-classifier/HashStore.cpp
+++ b/toolkit/components/url-classifier/HashStore.cpp
@@ -782,17 +782,19 @@ HashStore::ReadSubPrefixes()
 }
 
 // Split up PrefixArray back into the constituents
 nsresult
 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());
   }
 
   nsresult rv = ByteSliceWrite(aOut, chunks);
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/toolkit/components/url-classifier/LookupCache.cpp
+++ b/toolkit/components/url-classifier/LookupCache.cpp
@@ -559,17 +559,19 @@ static void EnsureSorted(T* aArray)
 #endif
 
 nsresult
 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());
   }
   aAddPrefixes.Clear();
 
 #ifdef DEBUG
   // PrefixSet requires sorted order