ruby-changes:40755
From: nobu <ko1@a...>
Date: Tue, 1 Dec 2015 23:14:34 +0900 (JST)
Subject: [ruby-changes:40755] nobu:r52834 (trunk): thread.c: check name argument
nobu 2015-12-01 23:14:07 +0900 (Tue, 01 Dec 2015) New Revision: 52834 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52834 Log: thread.c: check name argument * thread.c (rb_thread_setname): check the argument if valid string. [ruby-core:71774] [Bug #11756] Modified files: trunk/ChangeLog trunk/test/ruby/test_thread.rb trunk/thread.c Index: ChangeLog =================================================================== --- ChangeLog (revision 52833) +++ ChangeLog (revision 52834) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Dec 1 23:14:04 2015 Nobuyoshi Nakada <nobu@r...> + + * thread.c (rb_thread_setname): check the argument if valid + string. [ruby-core:71774] [Bug #11756] + Tue Dec 1 17:13:41 2015 Nobuyoshi Nakada <nobu@r...> * string.c (rb_string_value_cstr): should not raise on frozen Index: thread.c =================================================================== --- thread.c (revision 52833) +++ thread.c (revision 52834) @@ -2776,6 +2776,7 @@ rb_thread_setname(VALUE thread, VALUE na https://github.com/ruby/ruby/blob/trunk/thread.c#L2776 { rb_thread_t *th; GetThreadPtr(thread, th); + StringValueCStr(name); th->name = rb_str_new_frozen(name); #if defined(HAVE_PTHREAD_SETNAME_NP) # if defined(__linux__) Index: test/ruby/test_thread.rb =================================================================== --- test/ruby/test_thread.rb (revision 52833) +++ test/ruby/test_thread.rb (revision 52834) @@ -1057,4 +1057,22 @@ q.pop https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L1057 t.kill t.join end + + def test_thread_invalid_name + bug11756 = '[ruby-core:71774] [Bug #11756]' + t = Thread.start {} + assert_raise(ArgumentError, bug11756) {t.name = "foo\0bar"} + ensure + t.kill + t.join + end + + def test_thread_invalid_object + bug11756 = '[ruby-core:71774] [Bug #11756]' + t = Thread.start {} + assert_raise(TypeError, bug11756) {t.name = nil} + ensure + t.kill + t.join + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/