[前][次][番号順一覧][スレッド一覧]

ruby-changes:53469

From: shyouhei <ko1@a...>
Date: Mon, 12 Nov 2018 17:14:16 +0900 (JST)
Subject: [ruby-changes:53469] shyouhei:r65685 (trunk): vm_insnhelper.c: avoid nevative sp

shyouhei	2018-11-12 17:14:09 +0900 (Mon, 12 Nov 2018)

  New Revision: 65685

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65685

  Log:
    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

  Modified files:
    trunk/vm_insnhelper.c
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 65684)
+++ vm_insnhelper.c	(revision 65685)
@@ -1269,7 +1269,10 @@ vm_expandarray(VALUE *sp, VALUE ary, rb_ https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1269
 	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;
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]