ruby-changes:38691
From: ko1 <ko1@a...>
Date: Fri, 5 Jun 2015 01:08:54 +0900 (JST)
Subject: [ruby-changes:38691] ko1:r50772 (trunk): * vm_method.c (rb_add_method_iseq): use intermediate struct to
ko1 2015-06-05 01:08:40 +0900 (Fri, 05 Jun 2015) New Revision: 50772 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50772 Log: * vm_method.c (rb_add_method_iseq): use intermediate struct to avoid initializing struct with variables. [Bug #11217] * method.h: add a comment about it. Modified files: trunk/ChangeLog trunk/method.h trunk/vm_method.c Index: method.h =================================================================== --- method.h (revision 50771) +++ method.h (revision 50772) @@ -60,7 +60,7 @@ typedef struct rb_iseq_struct rb_iseq_t; https://github.com/ruby/ruby/blob/trunk/method.h#L60 typedef struct rb_method_iseq_struct { rb_iseq_t * const iseqptr; /* should be separated from iseqval */ rb_cref_t * const cref; /* shoudl be marked */ -} rb_method_iseq_t; +} rb_method_iseq_t; /* check rb_add_method_iseq() when modify the fields */ typedef struct rb_method_cfunc_struct { VALUE (*func)(ANYARGS); Index: ChangeLog =================================================================== --- ChangeLog (revision 50771) +++ ChangeLog (revision 50772) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jun 5 01:06:02 2015 Koichi Sasada <ko1@a...> + + * vm_method.c (rb_add_method_iseq): use intermediate struct to + avoid initializing struct with variables. + [Bug #11217] + + * method.h: add a comment about it. + Fri Jun 5 00:55:21 2015 Koichi Sasada <ko1@a...> * method.h: constify rb_method_refined_t::orig_me. Index: vm_method.c =================================================================== --- vm_method.c (revision 50771) +++ vm_method.c (revision 50772) @@ -562,11 +562,15 @@ void https://github.com/ruby/ruby/blob/trunk/vm_method.c#L562 rb_add_method_iseq(VALUE klass, ID mid, VALUE iseqval, rb_cref_t *cref, rb_method_visibility_t visi) { rb_iseq_t *iseq; + struct { /* should be same fields with rb_method_iseq_struct */ + rb_iseq_t *iseqptr; + rb_cref_t *cref; + } iseq_body; + GetISeqPtr(iseqval, iseq); - { - rb_method_iseq_t iseq_body = {iseq, cref}; - rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, &iseq_body, visi); - } + iseq_body.iseqptr = iseq; + iseq_body.cref = cref; + rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, &iseq_body, visi); } static rb_method_entry_t * -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/