summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-12 08:14:09 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-12 08:14:09 +0000
commit3208db7fb3403dfbfd1e81cc4b531f36d5cd5fff (patch)
treea3421b42245f6562547df33396d39ce8dc70afae
parent5a10e835ae67daa8e75d23a1b221ce4dc486bc1a (diff)
vm_insnhelper.c: avoid nevative sp
space_size can be zero here, under the following script. We would better bail out before bptr calculation. % ./miniruby --dump=i -e '* = nil' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,7)> (catch: FALSE) 0000 putnil ( 1)[Li] 0001 dup 0002 expandarray 0, 0 0005 leave git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--vm_insnhelper.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index e8dd174c9f..7fb18714dd 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1269,7 +1269,10 @@ vm_expandarray(VALUE *sp, VALUE ary, rb_num_t num, int flag)
len = (rb_num_t)RARRAY_LEN(ary);
}
- if (flag & 0x02) {
+ if (space_size == 0) {
+ /* no space left on stack */
+ }
+ else if (flag & 0x02) {
/* post: ..., nil ,ary[-1], ..., ary[0..-num] # top */
rb_num_t i = 0, j;