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 192879 18bd62a3aa7a8003ebebd8fa145e4268a410ff49
parent 192878 44bc3af856a4b4202864f9ed27aae1028d601b95
child 192880 32cfaa06b5a4866e048ae9735c13fa10fc63ef17
push id5942
push userryanvm@gmail.com
push dateWed, 28 May 2014 16:23:14 +0000
treeherdermozilla-aurora@32cfaa06b5a4 [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 || []);