summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-04 02:22:44 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-04 02:22:44 +0000
commit0ada28f906097f5ba370575a86aef1e42a9d7ba0 (patch)
treef8ead1284b2c53889ae186c7643c1cf8a48dcb8e /thread.c
parentb887c7c20ab81b50ed7cb8c7db3218c443985d6b (diff)
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
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index 1444383aa7..6e2d882768 100644
--- a/thread.c
+++ b/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);