summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--insns.def2
-rw-r--r--vm.c6
3 files changed, 9 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 09f2f8dc6a..75af323df6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/insns.def b/insns.def
index 792c8d40f1..27b52b01f4 100644
--- a/insns.def
+++ b/insns.def
@@ -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);
diff --git a/vm.c b/vm.c
index f4e37d28a7..487797818c 100644
--- a/vm.c
+++ b/vm.c
@@ -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];