From 34ac707ea34880e168dc2428d477a33ca7ffec7d Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 25 Jul 2016 11:34:55 +0900 Subject: OP_ASGN vsp may be negative reported by https://gist.github.com/miura1729/53fbd8af889c289a79108e38635b2378 fix proposed by @miura1729 in https://github.com/miura1729/mruby/commit/b1b7933f7aa950cfb747b06327a0d0340f3e4ff8 --- mrbgems/mruby-compiler/core/codegen.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mrbgems/mruby-compiler/core') diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index dde289e7c..6e9c3c147 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -1785,7 +1785,7 @@ codegen(codegen_scope *s, node *tree, int val) int pos; pop(); - if (val) { + if (val && vsp >= 0) { genop(s, MKOP_AB(OP_MOVE, vsp, cursp())); pos = genop(s, MKOP_AsBx(name[0]=='|'?OP_JMPIF:OP_JMPNOT, cursp(), 0)); } @@ -1794,7 +1794,7 @@ codegen(codegen_scope *s, node *tree, int val) } codegen(s, tree->cdr->cdr->car, VAL); pop(); - if (val) { + if (val && vsp >= 0) { genop(s, MKOP_AB(OP_MOVE, vsp, cursp())); } if ((intptr_t)tree->car->car == NODE_CALL) { @@ -1855,7 +1855,7 @@ codegen(codegen_scope *s, node *tree, int val) gen_assignment(s, tree->car, cursp(), val); } else { - if (val) { + if (val && vsp >= 0) { genop(s, MKOP_AB(OP_MOVE, vsp, cursp())); } if (callargs == CALL_MAXARGS) { -- cgit v1.2.3