diff --git a/lib/script/script.js b/lib/script/script.js index 3aedf8c2..34b84c6e 100644 --- a/lib/script/script.js +++ b/lib/script/script.js @@ -589,8 +589,11 @@ Script.prototype.execute = function execute(stack, flags, tx, index, value, vers if (op.isDisabled()) throw new ScriptError('DISABLED_OPCODE', op, ip); - if (negate && !op.isBranch()) + if (negate && !op.isBranch()) { + if (stack.length + alt.length > consensus.MAX_SCRIPT_STACK) + throw new ScriptError('STACK_SIZE', op, ip); continue; + } if (op.data) { if (minimal && !op.isMinimal())