Prevent infinite loops for corrupt options

This commit is contained in:
toasted-nutbread 2019-09-05 19:21:50 -04:00
parent bc7759d94c
commit 1c767711bb

View File

@ -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;
}