Skip to content

Commit 87aa303

Browse files
committed
Fix loop length detection in module
1 parent 1d1b92c commit 87aa303

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/core/sceneObjs/special/ModuleObj.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,12 @@ class ModuleObj extends BaseSceneObj {
670670
} else {
671671
let result = [];
672672
let loopVars1 = loopVars.slice(1);
673-
const loopLength = (loopVars[0].end - loopVars[0].start) / loopVars[0].step + 1;
673+
const span = loopVars[0].end - loopVars[0].start;
674+
const step = loopVars[0].step;
675+
if (step === 0 || span * step < 0) {
676+
throw i18next.t('simulator:sceneObjs.ModuleObj.loopVariableTooLarge', { name: loopVars[0].name });
677+
}
678+
const loopLength = span / step + 1;
674679
if (loopLength > (self.moduleDef.maxLoopLength || 1000)) {
675680
throw i18next.t('simulator:sceneObjs.ModuleObj.loopVariableTooLarge', { name: loopVars[0].name });
676681
}

0 commit comments

Comments
 (0)