Skip to content

Commit

Permalink
fix for stack overflow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cdetrio committed Jun 8, 2017
1 parent b83a928 commit 9edd6eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
exports.ERROR = {
OUT_OF_GAS: 'out of gas',
STACK_UNDERFLOW: 'stack underflow',
STACK_OVERFLOW: 'stack overflow',
INVALID_JUMP: 'invalid JUMP',
INVALID_OPCODE: 'invalid opcode'
}
7 changes: 4 additions & 3 deletions lib/runCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ module.exports = function (opts, cb) {
}

function iterateVm (done) {
if (runState.stack.length > 1024) {
return done(ERROR.INVALID_OPCODE)
}

var opCode = runState.code[runState.programCounter]
var opInfo = lookupOpInfo(opCode)
Expand All @@ -131,6 +128,10 @@ module.exports = function (opts, cb) {
return done(ERROR.STACK_UNDERFLOW)
}

if ((runState.stack.length - opInfo.in + opInfo.out) > 1024) {
return done(ERROR.STACK_OVERFLOW)
}

async.series([
runStepHook,
runOp
Expand Down

0 comments on commit 9edd6eb

Please sign in to comment.