ruby-changes:39179
From: normal <ko1@a...>
Date: Thu, 16 Jul 2015 03:11:19 +0900 (JST)
Subject: [ruby-changes:39179] normal:r51260 (trunk): thread.c (thread_initialize): avoid RSTRING_PTR and NUMT2INT
normal 2015-07-16 03:11:05 +0900 (Thu, 16 Jul 2015) New Revision: 51260 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51260 Log: 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. Modified files: trunk/ChangeLog trunk/thread.c Index: ChangeLog =================================================================== --- ChangeLog (revision 51259) +++ ChangeLog (revision 51260) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Jul 16 02:56:14 2015 Eric Wong <e@8...> + + * thread.c (thread_initialize): avoid RSTRING_PTR and NUMT2INT + Thu Jul 16 01:00:46 2015 Naohisa Goto <ngotogenome@g...> * test/ruby/test_process.rb (test_exec_close_reserved_fd): test for Index: thread.c =================================================================== --- thread.c (revision 51259) +++ thread.c (revision 51260) @@ -769,17 +769,18 @@ thread_initialize(VALUE thread, VALUE ar https://github.com/ruby/ruby/blob/trunk/thread.c#L769 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); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/