From e26c2bc21baac04ab52bff4eeedd9f41e4cb1f31 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 29 Jan 2013 07:50:27 +0000 Subject: 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 --- test/ruby/test_settracefunc.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/ruby/test_settracefunc.rb') diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index af97651493..264b805127 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -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 -- cgit v1.2.3