Bug 1141788 - Use strong references during iteration in nsSHistory. r=smaug
authorAndrew McCreight <continuation@gmail.com>
Fri, 29 Jul 2016 16:08:06 -0700
changeset 349477 2882620cd75fe1984479f4d6a9b1982ee95a00e4
parent 349476 fcc56a97afb3beb1786a205d4634e377efbf4ebe
child 349478 a79fd415865ed313ffae5119b27f0a057237b7fb
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)
reviewerssmaug
bugs1141788
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 1141788 - Use strong references during iteration in nsSHistory. r=smaug MozReview-Commit-ID: DO1fJAZrYT
docshell/shistory/nsSHistory.cpp
--- a/docshell/shistory/nsSHistory.cpp
+++ b/docshell/shistory/nsSHistory.cpp
@@ -792,17 +792,17 @@ NS_IMETHODIMP
 nsSHistory::EvictAllContentViewers()
 {
   // XXXbz we don't actually do a good job of evicting things as we should, so
   // we might have viewers quite far from mIndex.  So just evict everything.
   nsCOMPtr<nsISHTransaction> trans = mListRoot;
   while (trans) {
     EvictContentViewerForTransaction(trans);
 
-    nsISHTransaction* temp = trans;
+    nsCOMPtr<nsISHTransaction> temp = trans;
     temp->GetNext(getter_AddRefs(trans));
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHistory::GetCanGoBack(bool* aCanGoBack)
@@ -969,29 +969,29 @@ nsSHistory::EvictOutOfRangeWindowContent
   // evicted.  Collect a set of them so we don't accidentally evict one of them
   // if it appears outside this range.
   nsCOMArray<nsIContentViewer> safeViewers;
   nsCOMPtr<nsISHTransaction> trans;
   GetTransactionAtIndex(startSafeIndex, getter_AddRefs(trans));
   for (int32_t i = startSafeIndex; trans && i <= endSafeIndex; i++) {
     nsCOMPtr<nsIContentViewer> viewer = GetContentViewerForTransaction(trans);
     safeViewers.AppendObject(viewer);
-    nsISHTransaction* temp = trans;
+    nsCOMPtr<nsISHTransaction> temp = trans;
     temp->GetNext(getter_AddRefs(trans));
   }
 
   // Walk the SHistory list and evict any content viewers that aren't safe.
   GetTransactionAtIndex(0, getter_AddRefs(trans));
   while (trans) {
     nsCOMPtr<nsIContentViewer> viewer = GetContentViewerForTransaction(trans);
     if (safeViewers.IndexOf(viewer) == -1) {
       EvictContentViewerForTransaction(trans);
     }
 
-    nsISHTransaction* temp = trans;
+    nsCOMPtr<nsISHTransaction> temp = trans;
     temp->GetNext(getter_AddRefs(trans));
   }
 }
 
 namespace {
 
 class TransactionAndDistance
 {
@@ -1103,17 +1103,17 @@ nsSHistory::GloballyEvictContentViewers(
         // make a new one.
         if (!found) {
           TransactionAndDistance container(trans,
                                            DeprecatedAbs(i - shist->mIndex));
           shTransactions.AppendElement(container);
         }
       }
 
-      nsISHTransaction* temp = trans;
+      nsCOMPtr<nsISHTransaction> temp = trans;
       temp->GetNext(getter_AddRefs(trans));
     }
 
     // We've found all the transactions belonging to shist which have viewers.
     // Add those transactions to our global list and move on.
     transactions.AppendElements(shTransactions);
     listEntry = PR_NEXT_LINK(shist);
   }
@@ -1149,17 +1149,17 @@ nsSHistory::EvictExpiredContentViewerFor
     nsCOMPtr<nsISHEntry> entry;
     trans->GetSHEntry(getter_AddRefs(entry));
 
     // Does entry have the same BFCacheEntry as the argument to this method?
     if (entry->HasBFCacheEntry(aEntry)) {
       break;
     }
 
-    nsISHTransaction* temp = trans;
+    nsCOMPtr<nsISHTransaction> temp = trans;
     temp->GetNext(getter_AddRefs(trans));
   }
   if (i > endIndex) {
     return NS_OK;
   }
 
   if (i == mIndex) {
     NS_WARNING("How did the current SHEntry expire?");