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

block->tag pointing out of stack

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1999-10-13 09:32:16 +00:00
parent ec8a9bba35
commit 826f10c6ce
2 changed files with 16 additions and 3 deletions

View file

@ -1,5 +1,11 @@
Wed Oct 13 02:17:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp> Wed Oct 13 02:17:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (block_pass): should copy block to prevent modifications.
tag in the structure should be updated from latest prot_tag.
* eval.c (proc_s_new): tag in struct BLOCK should not point into
unused stack.
* dir.c (dir_s_glob): iterate over generated matching filenames if * dir.c (dir_s_glob): iterate over generated matching filenames if
the block is given to the method. the block is given to the method.

13
eval.c
View file

@ -5549,6 +5549,7 @@ proc_s_new(klass)
data->orig_thread = rb_thread_current(); data->orig_thread = rb_thread_current();
data->iter = data->prev?Qtrue:Qfalse; data->iter = data->prev?Qtrue:Qfalse;
data->tag = 0; /* should not point into stack */
frame_dup(&data->frame); frame_dup(&data->frame);
if (data->iter) { if (data->iter) {
blk_copy_prev(data); blk_copy_prev(data);
@ -5589,6 +5590,7 @@ proc_call(proc, args)
VALUE proc, args; /* OK */ VALUE proc, args; /* OK */
{ {
struct BLOCK * volatile old_block; struct BLOCK * volatile old_block;
struct BLOCK _block;
struct BLOCK *data; struct BLOCK *data;
volatile VALUE result = Qnil; volatile VALUE result = Qnil;
int state; int state;
@ -5600,7 +5602,8 @@ proc_call(proc, args)
/* PUSH BLOCK from data */ /* PUSH BLOCK from data */
old_block = ruby_block; old_block = ruby_block;
ruby_block = data; _block = *data;
ruby_block = &_block;
PUSH_ITER(ITER_CUR); PUSH_ITER(ITER_CUR);
ruby_frame->iter = ITER_CUR; ruby_frame->iter = ITER_CUR;
@ -5625,6 +5628,7 @@ proc_call(proc, args)
} }
PUSH_TAG(PROT_NONE); PUSH_TAG(PROT_NONE);
_block.tag = prot_tag;
state = EXEC_TAG(); state = EXEC_TAG();
if (state == 0) { if (state == 0) {
proc_set_safe_level(proc); proc_set_safe_level(proc);
@ -5690,6 +5694,7 @@ block_pass(self, node)
{ {
VALUE block = rb_eval(self, node->nd_body); VALUE block = rb_eval(self, node->nd_body);
struct BLOCK * volatile old_block; struct BLOCK * volatile old_block;
struct BLOCK _block;
struct BLOCK *data; struct BLOCK *data;
volatile VALUE result = Qnil; volatile VALUE result = Qnil;
int state; int state;
@ -5712,11 +5717,13 @@ block_pass(self, node)
/* PUSH BLOCK from data */ /* PUSH BLOCK from data */
old_block = ruby_block; old_block = ruby_block;
ruby_block = data; _block = *data;
ruby_block = &_block;
PUSH_ITER(ITER_PRE); PUSH_ITER(ITER_PRE);
ruby_frame->iter = ITER_PRE; ruby_frame->iter = ITER_PRE;
PUSH_TAG(PROT_NONE); PUSH_TAG(PROT_NONE);
_block.tag = prot_tag;
state = EXEC_TAG(); state = EXEC_TAG();
if (state == 0) { if (state == 0) {
proc_set_safe_level(block); proc_set_safe_level(block);
@ -5724,7 +5731,7 @@ block_pass(self, node)
} }
POP_TAG(); POP_TAG();
POP_ITER(); POP_ITER();
if (ruby_block->tag->dst == state) { if (_block.tag->dst == state) {
state &= TAG_MASK; state &= TAG_MASK;
orphan = 2; orphan = 2;
} }