summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-15 18:11:05 (GMT)
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-15 18:11:05 (GMT)
commit5522e010e55a3bdeaed400ffca675e3a8e468257 (patch)
tree8724624d8faa6bbd372f1ef823fa8ae603640a8b /thread.c
parent66a36e9b13e3e7eee3ecc4f844be72416d1863cf (diff)
thread.c (thread_initialize): avoid RSTRING_PTR and NUMT2INT
Favor passing VALUE args as-is and using PRisVALUE in format strings to prevent premature GC. In this case, we are not fixing any real bug because location path has other references, but this makes code easier-to-review. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/thread.c b/thread.c
index f80fcf6..95b022f 100644
--- a/thread.c
+++ b/thread.c
@@ -769,17 +769,18 @@ thread_initialize(VALUE thread, VALUE args)
GetThreadPtr(thread, th);
if (th->first_args) {
VALUE proc = th->first_proc, line, loc;
- const char *file;
+ VALUE file;
if (!proc || !RTEST(loc = rb_proc_location(proc))) {
rb_raise(rb_eThreadError, "already initialized thread");
}
- file = RSTRING_PTR(RARRAY_AREF(loc, 0));
+ file = RARRAY_AREF(loc, 0);
if (NIL_P(line = RARRAY_AREF(loc, 1))) {
- rb_raise(rb_eThreadError, "already initialized thread - %s",
- file);
+ rb_raise(rb_eThreadError,
+ "already initialized thread - %"PRIsVALUE, file);
}
- rb_raise(rb_eThreadError, "already initialized thread - %s:%d",
- file, NUM2INT(line));
+ rb_raise(rb_eThreadError,
+ "already initialized thread - %"PRIsVALUE":%"PRIsVALUE,
+ file, line);
}
return thread_create_core(thread, args, 0);
}