diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-09-05 19:21:50 -0400 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-09-05 20:57:52 -0400 |
commit | 1c767711bb553fa828596f95f8ed9e91a3e13b5d (patch) | |
tree | 99b1ab125b59ae63a0a757fe0c055246451efec8 /ext | |
parent | bc7759d94c4d4bbe2480e5328a4c3488ff29e493 (diff) |
Prevent infinite loops for corrupt options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/bg/js/options.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index df95aae9..d903250e 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -305,14 +305,19 @@ function optionsVersion(options) { ]; optionsSetDefaults(options); - if (!options.hasOwnProperty('version')) { - options.version = fixups.length; + + let version = options.version; + if (typeof version !== 'number' || !Number.isFinite(version)) { + version = fixups.length; + } else { + version = Math.max(0, Math.floor(version)); } - while (options.version < fixups.length) { - fixups[options.version++](); + for (; version < fixups.length; ++version) { + fixups[version](); } + options.version = version; return options; } |