1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* insns.def, vm.c: add/fix stack overflow check.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-06-24 08:55:17 +00:00
parent adc677eb5c
commit f2074245b4
3 changed files with 9 additions and 3 deletions

View file

@ -1,3 +1,7 @@
Sun Jun 24 17:54:13 2007 Koichi Sasada <ko1@atdot.net>
* insns.def, vm.c: add/fix stack overflow check.
Sun Jun 24 17:28:52 2007 Koichi Sasada <ko1@atdot.net>
* insnhelper.h: change CHECK_STACK_OVERFLOW() to throw exception.

View file

@ -1329,8 +1329,10 @@ invokeblock
if (BUILTIN_TYPE(iseq) != T_NODE) {
argc = caller_setup_args(th, GET_CFP(), flag, argc, 0, 0);
CHECK_STACK_OVERFLOW(GET_CFP(), iseq->stack_max);
DEC_SP(argc);
argc = th_yield_setup_args(th, iseq, argc, GET_SP(),
block_proc_is_lambda(block->proc));
INC_SP(argc);

6
vm.c
View file

@ -871,7 +871,7 @@ th_yield_setup_args(rb_thread_t *th, rb_iseq_t *iseq,
VALUE ary = argv[0];
th->mark_stack_len = argc = RARRAY_LEN(ary);
/* TODO: check overflow */
CHECK_STACK_OVERFLOW(th->cfp, argc);
for (i=0; i<argc; i++) {
argv[i] = RARRAY_PTR(ary)[i];
@ -906,7 +906,6 @@ th_yield_setup_args(rb_thread_t *th, rb_iseq_t *iseq,
argc, iseq->argc);
}
else {
/* TODO: check overflow */
for (i=argc; i<r; i++) {
argv[i] = Qnil;
}
@ -946,7 +945,8 @@ invoke_block(rb_thread_t *th, rb_block_t *block, VALUE self, int argc, VALUE *ar
th_set_finish_env(th);
/* TODO: check overflow */
CHECK_STACK_OVERFLOW(th->cfp, argc);
CHECK_STACK_OVERFLOW(th->cfp, iseq->stack_max);
for (i=0; i<argc; i++) {
th->cfp->sp[i] = argv[i];