From 3d912e3aff446320600573aac4d92d4070323a47 Mon Sep 17 00:00:00 2001 From: Sam Foster Date: Thu, 23 Jan 2014 16:58:33 -0800 Subject: [PATCH] Bug 960740 - skip writing session state data if it fails sanity check. r=msamuel --- browser/metro/components/SessionStore.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/browser/metro/components/SessionStore.js b/browser/metro/components/SessionStore.js index dee3d5b54f48..8245fc59e54d 100644 --- a/browser/metro/components/SessionStore.js +++ b/browser/metro/components/SessionStore.js @@ -272,7 +272,7 @@ SessionStore.prototype = { this.saveState(); } break; - case "browser:purge-session-history": // catch sanitization + case "browser:purge-session-history": // catch sanitization this._clearDisk(); // If the browser is shutting down, simply return after clearing the @@ -514,9 +514,14 @@ SessionStore.prototype = { saveState: function ss_saveState() { let data = this._getCurrentState(); - this._writeFile(this._sessionFile, JSON.stringify(data)); + // sanity check before we overwrite the session file + if (data.windows && data.windows.length && data.selectedWindow) { + this._writeFile(this._sessionFile, JSON.stringify(data)); - this._lastSaveTime = Date.now(); + this._lastSaveTime = Date.now(); + } else { + dump("SessionStore: Not saving state with invalid data: " + JSON.stringify(data) + "\n"); + } }, _getCurrentState: function ss_getCurrentState() { @@ -847,7 +852,7 @@ SessionStore.prototype = { tab.browser.__SS_extdata = tabData.extData; } - + notifyObservers(); }.bind(this)); } catch (ex) {