diff --git a/src/playground/blocks/hardware/block_KKMOO.js b/src/playground/blocks/hardware/block_KKMOO.js index 972b5a4af2..44dd69ec74 100644 --- a/src/playground/blocks/hardware/block_KKMOO.js +++ b/src/playground/blocks/hardware/block_KKMOO.js @@ -651,9 +651,16 @@ Entry.kkmoo.getBlocks = function () { class: 'Make_Motion', isNotFor: ['kkmoo'], func: function (sprite, script) { - const motnum = script.getField('MOTNUM', script); + const motnum = Number(script.getField('MOTNUM', script)); const angle = script.getValue('ANGLE', script); Entry.hw.update(); + if ( + !Number.isInteger(motnum) || + motnum < 0 || + motnum >= Entry.kkmoo.motData.length + ) { + return script; + } if (script.isStart != true) { script.isStart = true; if (angle >= -90 && angle <= 90) { @@ -853,8 +860,15 @@ Entry.kkmoo.getBlocks = function () { class: 'Save_Motion', isNotFor: ['kkmoo'], func: function (sprite, script) { - const motnum = script.getField('FRAME', script); + const motnum = Number(script.getField('FRAME', script)); Entry.hw.update(); + if ( + !Number.isInteger(motnum) || + motnum < 0 || + motnum >= Entry.kkmoo.motionFrame.length + ) { + return script; + } if (script.isStart != true) { script.isStart = true; var data = Entry.kkmoo.copyObj(Entry.kkmoo.motData); @@ -972,9 +986,16 @@ Entry.kkmoo.getBlocks = function () { class: 'Save_Motion', isNotFor: ['kkmoo'], func: function (sprite, script) { - const motnum = script.getField('FRAME', script); + const motnum = Number(script.getField('FRAME', script)); const time = script.getValue('TIME', script); Entry.hw.update(); + if ( + !Number.isInteger(motnum) || + motnum < 0 || + motnum >= Entry.kkmoo.motionFrame.length + ) { + return script; + } if (script.isStart != true) { script.isStart = true; Entry.kkmoo.motionFrame[motnum].time = time; diff --git a/src/playground/scope.js b/src/playground/scope.js index bcf714db76..b3b0b8b388 100644 --- a/src/playground/scope.js +++ b/src/playground/scope.js @@ -27,7 +27,11 @@ class Scope { static _reservedKeywords = new Set(['__proto__']); filterReservedKeywords(param) { - return Scope._reservedKeywords.has(param) ? '' : param; + // 배열/객체를 객체 키로 사용할 때 toString 변환(예: ["__proto__"] → "__proto__")으로 + // 예약어를 우회하는 것을 차단한다. + const normalized = + typeof param === 'object' && param !== null ? String(param) : param; + return Scope._reservedKeywords.has(normalized) ? '' : param; } getParams() {