vm_trace.c: trace_func safe level check

* vm_trace.c (set_trace_func, thread_{add,set}_trace_func_m): check
  safe level as well as 1.8.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-01-29 07:50:27 +00:00
parent b0c4ac7779
commit e26c2bc21b
3 changed files with 43 additions and 0 deletions

View file

@ -397,6 +397,38 @@ class TestSetTraceFunc < Test::Unit::TestCase
assert_equal(self, ok, bug3921)
end
def assert_security_error_safe4
func = lambda {
$SAFE = 4
proc {yield}
}.call
assert_raise(SecurityError, &func)
end
def test_set_safe4
assert_security_error_safe4 do
set_trace_func(lambda {|*|})
end
end
def test_thread_set_safe4
th = Thread.start {sleep}
assert_security_error_safe4 do
th.set_trace_func(lambda {|*|})
end
ensure
th.kill
end
def test_thread_add_safe4
th = Thread.start {sleep}
assert_security_error_safe4 do
th.add_trace_func(lambda {|*|})
end
ensure
th.kill
end
class << self
define_method(:method_added, Module.method(:method_added))
end