mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
thread.c: name must be ascii-compatible
* thread.c (rb_thread_setname): name must be ascii-compatible, as pthread APIs do not accept legacy wide char strings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b887c7c20a
commit
0ada28f906
3 changed files with 12 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Dec 4 11:22:40 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* thread.c (rb_thread_setname): name must be ascii-compatible, as
|
||||
pthread APIs do not accept legacy wide char strings.
|
||||
|
||||
Thu Dec 3 16:02:17 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (rb_obj_as_string): fstring should not be infected.
|
||||
|
|
|
@ -1067,6 +1067,7 @@ q.pop
|
|||
bug11756 = '[ruby-core:71774] [Bug #11756]'
|
||||
t = Thread.start {}
|
||||
assert_raise(ArgumentError, bug11756) {t.name = "foo\0bar"}
|
||||
assert_raise(ArgumentError, bug11756) {t.name = "foo".encode(Encoding::UTF_32BE)}
|
||||
ensure
|
||||
t.kill
|
||||
t.join
|
||||
|
|
6
thread.c
6
thread.c
|
@ -2780,7 +2780,13 @@ rb_thread_setname(VALUE thread, VALUE name)
|
|||
rb_thread_t *th;
|
||||
GetThreadPtr(thread, th);
|
||||
if (!NIL_P(name)) {
|
||||
rb_encoding *enc;
|
||||
StringValueCStr(name);
|
||||
enc = rb_enc_get(name);
|
||||
if (!rb_enc_asciicompat(enc)) {
|
||||
rb_raise(rb_eArgError, "ASCII incompatible encoding (%s)",
|
||||
rb_enc_name(enc));
|
||||
}
|
||||
name = rb_str_new_frozen(name);
|
||||
#ifdef SET_ANOTHER_THREAD_NAME
|
||||
s = RSTRING_PTR(name);
|
||||
|
|
Loading…
Add table
Reference in a new issue