Bug 1159500 - Crash in mozilla::net::CacheIndexIterator::GetNextHash(unsigned char (*)[20]). r=honzab, a=sledru
authorMichal Novotny <michal.novotny@gmail.com>
Sat, 23 May 2015 09:12:43 +0200
changeset 266103 2b23a8be4f93
parent 266102 8b33b6374feb
child 266104 50bf62afd416
push id4755
push userryanvm@gmail.com
push date2015-05-25 19:46 +0000
treeherdermozilla-beta@46bb07934327 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershonzab, sledru
bugs1159500
milestone39.0
Bug 1159500 - Crash in mozilla::net::CacheIndexIterator::GetNextHash(unsigned char (*)[20]). r=honzab, a=sledru
netwerk/cache2/CacheIndex.cpp
--- a/netwerk/cache2/CacheIndex.cpp
+++ b/netwerk/cache2/CacheIndex.cpp
@@ -1072,16 +1072,27 @@ CacheIndex::RemoveAll()
     MOZ_ASSERT(!index->mJournalHandle);
 
     index->mIndexOnDiskIsValid = false;
     index->mIndexNeedsUpdate = false;
 
     index->mIndexStats.Clear();
     index->mFrecencyArray.Clear();
     index->mIndex.Clear();
+
+    for (uint32_t i = 0; i < index->mIterators.Length(); ) {
+      nsresult rv = index->mIterators[i]->CloseInternal(NS_ERROR_NOT_AVAILABLE);
+      if (NS_FAILED(rv)) {
+        // CacheIndexIterator::CloseInternal() removes itself from mIterators
+        // iff it returns success.
+        LOG(("CacheIndex::RemoveAll() - Failed to remove iterator %p. "
+             "[rv=0x%08x]", rv));
+        i++;
+      }
+    }
   }
 
   if (file) {
     // Ignore the result. The file might not exist and the failure is not fatal.
     file->Remove(false);
   }
 
   return NS_OK;