Bug 1594850 - Part 1 - Fix crash in nsSHistory::EnsureCorrectEntryAtCurrIndex when mIndex=-1, r=peterv
authorAnny Gakhokidze <agakhokidze@mozilla.com>
Thu, 14 Nov 2019 20:09:58 +0000
changeset 502044 3af47ccb969a9c50101c1efffbefc5eaece26bb4
parent 502043 0ee40940310074484845f8d2849896f0fe17cf83
child 502045 11ce58dd19022bd0d8c7f4da372b6f1134623474
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1594850
milestone72.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 1594850 - Part 1 - Fix crash in nsSHistory::EnsureCorrectEntryAtCurrIndex when mIndex=-1, r=peterv Differential Revision: https://phabricator.services.mozilla.com/D52370
docshell/shistory/nsSHistory.cpp
--- a/docshell/shistory/nsSHistory.cpp
+++ b/docshell/shistory/nsSHistory.cpp
@@ -1374,18 +1374,17 @@ nsSHistory::GotoIndex(int32_t aIndex) {
   NS_ENSURE_SUCCESS(rv, rv);
 
   return LoadURI(loadResult);
 }
 
 NS_IMETHODIMP_(void)
 nsSHistory::EnsureCorrectEntryAtCurrIndex(nsISHEntry* aEntry) {
   int index = mRequestedIndex == -1 ? mIndex : mRequestedIndex;
-  MOZ_ASSERT(mIndex > -1);
-  if (mEntries[index] != aEntry) {
+  if (index > -1 && (mEntries[index] != aEntry)) {
     ReplaceEntry(index, aEntry);
   }
 }
 
 nsresult nsSHistory::GotoIndex(int32_t aIndex, LoadEntryResult& aLoadResult) {
   return LoadEntry(aIndex, LOAD_HISTORY, HIST_CMD_GOTOINDEX, aLoadResult);
 }