* safe.c (rb_set_safe_level): call `rb_vm_stack_to_heap()`
  to set block parameter.

* safe.c (rb_set_safe_level): use `GET_EC()`.

* safe.c (safe_setter): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-10-29 15:38:55 +00:00
Родитель 735129aa90
Коммит 6d11719b0e
1 изменённых файлов: 10 добавлений и 7 удалений

17
safe.c
Просмотреть файл

@ -46,13 +46,16 @@ rb_set_safe_level_force(int safe)
void void
rb_set_safe_level(int level) rb_set_safe_level(int level)
{ {
rb_thread_t *th = GET_THREAD(); rb_execution_context_t *ec = GET_EC();
if (level > th->ec->safe_level) { if (level > ec->safe_level) {
if (level > SAFE_LEVEL_MAX) { if (level > SAFE_LEVEL_MAX) {
rb_raise(rb_eArgError, "$SAFE=2 to 4 are obsolete"); rb_raise(rb_eArgError, "$SAFE=2 to 4 are obsolete");
} }
th->ec->safe_level = level; /* block parameters */
rb_vm_stack_to_heap(ec);
ec->safe_level = level;
} }
} }
@ -65,8 +68,8 @@ safe_getter(void)
static void static void
safe_setter(VALUE val) safe_setter(VALUE val)
{ {
rb_thread_t *th = GET_THREAD(); rb_execution_context_t *ec = GET_EC();
int current_level = th->ec->safe_level; int current_level = ec->safe_level;
int level = NUM2INT(val); int level = NUM2INT(val);
if (level == current_level) { if (level == current_level) {
@ -82,9 +85,9 @@ safe_setter(VALUE val)
} }
/* block parameters */ /* block parameters */
rb_vm_stack_to_heap(th->ec); rb_vm_stack_to_heap(ec);
th->ec->safe_level = level; ec->safe_level = level;
} }
void void