Bug 1014238 - Don't break on invalid customization state. r=jaws, a=lsblakk
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 22 May 2014 00:35:57 +0100
changeset 199345 18bd62a3aa7a8003ebebd8fa145e4268a410ff49
parent 199344 44bc3af856a4b4202864f9ed27aae1028d601b95
child 199346 32cfaa06b5a4866e048ae9735c13fa10fc63ef17
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, lsblakk
bugs1014238
milestone31.0a2
Bug 1014238 - Don't break on invalid customization state. r=jaws, a=lsblakk
browser/components/customizableui/src/CustomizableUI.jsm
--- a/browser/components/customizableui/src/CustomizableUI.jsm
+++ b/browser/components/customizableui/src/CustomizableUI.jsm
@@ -1692,17 +1692,22 @@ let CustomizableUIInternal = {
       // the defaults.
     }
 
     if (!state) {
       return;
     }
     try {
       gSavedState = JSON.parse(state);
+      if (typeof gSavedState != "object" || gSavedState === null) {
+        throw "Invalid saved state";
+      }
     } catch(e) {
+      Services.prefs.clearUserPref(kPrefCustomizationState);
+      gSavedState = {};
       LOG("Error loading saved UI customization state, falling back to defaults.");
     }
 
     if (!("placements" in gSavedState)) {
       gSavedState.placements = {};
     }
 
     gSeenWidgets = new Set(gSavedState.seen || []);