commit 8d14e444492dc12aaa86fb7c9cbfa3a2cdc2a156
parent 7d48ba4837caf3e71b832b0803eeec30c187a050
Author: Adam Vandolder <avandolder@mozilla.com>
Date: Thu, 6 Nov 2025 15:44:36 +0000
Bug 1998653 - Defensively remove all SH entries from the entrylist before reconstructing during session restore. r=dom-core,farre
Differential Revision: https://phabricator.services.mozilla.com/D271608
Diffstat:
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/docshell/shistory/nsSHistory.cpp b/docshell/shistory/nsSHistory.cpp
@@ -2506,13 +2506,25 @@ void nsSHistory::ReconstructContiguousEntryListFrom(
SessionHistoryEntry* aEntry) {
RefPtr entryList = EntryListFor(aEntry->DocshellID());
entryList->clear();
+
+ if (aEntry->isInList()) {
+ aEntry->remove();
+ }
entryList->insertBack(aEntry);
+
for (auto* entry = aEntry;
(entry = FindAdjacentContiguousEntryFor(entry, -1));) {
+ if (entry->isInList()) {
+ entry->remove();
+ }
entryList->insertFront(entry);
}
+
for (auto* entry = aEntry;
(entry = FindAdjacentContiguousEntryFor(entry, 1));) {
+ if (entry->isInList()) {
+ entry->remove();
+ }
entryList->insertBack(entry);
}
}