Bug 1251253 - prevent null pointer dereference of |aContext| in CacheStorageService::DoomStorageEntries. r?mayhemer draft
authorBogdan Postelnicu <bogdan.postelnicu@softvision.ro>
Thu, 25 Feb 2016 20:41:52 +0200
changeset 334874 d73238c13b2d0ea193711c348da810c8205cf6f4
parent 334720 918df3a0bc1c4d07299e4f66274a7da923534577
child 515016 4f61aca1549d0d5659af239c126d9761855ff97c
push id11659
push userBogdan.Postelnicu@softvision.ro
push dateFri, 26 Feb 2016 12:59:11 +0000
reviewersmayhemer
bugs1251253
milestone47.0a1
Bug 1251253 - prevent null pointer dereference of |aContext| in CacheStorageService::DoomStorageEntries. r?mayhemer MozReview-Commit-ID: BmXXg4eW25n
netwerk/cache2/CacheStorageService.cpp
--- a/netwerk/cache2/CacheStorageService.cpp
+++ b/netwerk/cache2/CacheStorageService.cpp
@@ -1794,25 +1794,29 @@ CacheStorageService::DoomStorageEntries(
         RemoveExactEntry(diskEntries, iter.Key(), entry, false);
       }
     }
   }
 
   {
     mozilla::MutexAutoLock lock(mForcedValidEntriesLock);
 
-    for (auto iter = mForcedValidEntries.Iter(); !iter.Done(); iter.Next()) {
-      bool matches;
-      DebugOnly<nsresult> rv = CacheFileUtils::KeyMatchesLoadContextInfo(
-        iter.Key(), aContext, &matches);
-      MOZ_ASSERT(NS_SUCCEEDED(rv));
+    if (aContext) {
+      for (auto iter = mForcedValidEntries.Iter(); !iter.Done(); iter.Next()) {
+        bool matches;
+        DebugOnly<nsresult> rv = CacheFileUtils::KeyMatchesLoadContextInfo(
+          iter.Key(), aContext, &matches);
+        MOZ_ASSERT(NS_SUCCEEDED(rv));
 
-      if (matches) {
-        iter.Remove();
+        if (matches) {
+          iter.Remove();
+        }
       }
+    } else {
+      mForcedValidEntries.Clear();
     }
   }
 
   // An artificial callback.  This is a candidate for removal tho.  In the new
   // cache any 'doom' or 'evict' function ensures that the entry or entries
   // being doomed is/are not accessible after the function returns.  So there is
   // probably no need for a callback - has no meaning.  But for compatibility
   // with the old cache that is still in the tree we keep the API similar to be