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 267565 2b23a8be4f936ee01a41abd55595b5dc12d871c7
parent 267564 8b33b6374feb296fcf36a43f5b2799e213d7698e
child 267566 50bf62afd41635671d7f18410b61dccec0887207
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [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;