thread.c: check name argument
* thread.c (rb_thread_setname): check the argument if valid string. [ruby-core:71774] [Bug #11756] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d58f17f37d
commit
c56d9aaabf
@ -1,3 +1,8 @@
|
|||||||
|
Tue Dec 1 23:14:04 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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@ruby-lang.org>
|
Tue Dec 1 17:13:41 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* string.c (rb_string_value_cstr): should not raise on frozen
|
* string.c (rb_string_value_cstr): should not raise on frozen
|
||||||
|
@ -1057,4 +1057,22 @@ q.pop
|
|||||||
t.kill
|
t.kill
|
||||||
t.join
|
t.join
|
||||||
end
|
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
|
end
|
||||||
|
1
thread.c
1
thread.c
@ -2776,6 +2776,7 @@ rb_thread_setname(VALUE thread, VALUE name)
|
|||||||
{
|
{
|
||||||
rb_thread_t *th;
|
rb_thread_t *th;
|
||||||
GetThreadPtr(thread, th);
|
GetThreadPtr(thread, th);
|
||||||
|
StringValueCStr(name);
|
||||||
th->name = rb_str_new_frozen(name);
|
th->name = rb_str_new_frozen(name);
|
||||||
#if defined(HAVE_PTHREAD_SETNAME_NP)
|
#if defined(HAVE_PTHREAD_SETNAME_NP)
|
||||||
# if defined(__linux__)
|
# if defined(__linux__)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user