diff --git a/browser/components/sessionstore/src/nsSessionStore.js b/browser/components/sessionstore/src/nsSessionStore.js index 8f31971b4eb..ca86d9e714f 100644 --- a/browser/components/sessionstore/src/nsSessionStore.js +++ b/browser/components/sessionstore/src/nsSessionStore.js @@ -1659,8 +1659,9 @@ SessionStoreService.prototype = { } // when overwriting tabs, remove all superflous ones - for (t = openTabCount - 1; t >= newTabCount; t--) { - tabbrowser.removeTab(tabbrowser.mTabs[t]); + if (aOverwriteTabs && newTabCount < openTabCount) { + Array.slice(tabbrowser.mTabs, newTabCount, openTabCount) + .forEach(tabbrowser.removeTab, tabbrowser); } if (aOverwriteTabs) {