ruby-changes:42627
From: nobu <ko1@a...>
Date: Fri, 22 Apr 2016 18:08:11 +0900 (JST)
Subject: [ruby-changes:42627] nobu:r54701 (trunk): variable.c: fix implicit conversion
nobu 2016-04-22 19:04:47 +0900 (Fri, 22 Apr 2016) New Revision: 54701 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54701 Log: variable.c: fix implicit conversion Modified files: trunk/variable.c Index: variable.c =================================================================== --- variable.c (revision 54700) +++ variable.c (revision 54701) @@ -1079,11 +1079,12 @@ gen_ivtbl_dup(const struct gen_ivtbl *or https://github.com/ruby/ruby/blob/trunk/variable.c#L1079 static uint32_t iv_index_tbl_newsize(struct ivar_update *ivup) { - uint32_t newsize = (ivup->index+1) + (ivup->index+1)/4; /* (index+1)*1.25 */ + uint32_t index = (uint32_t)ivup->index; /* should not overflow */ + uint32_t newsize = (index+1) + (index+1)/4; /* (index+1)*1.25 */ if (!ivup->iv_extended && ivup->u.iv_index_tbl->num_entries < (st_index_t)newsize) { - newsize = ivup->u.iv_index_tbl->num_entries; + newsize = (uint32_t)ivup->u.iv_index_tbl->num_entries; } return newsize; } @@ -1381,7 +1382,7 @@ rb_ivar_set(VALUE obj, ID id, VALUE val) https://github.com/ruby/ruby/blob/trunk/variable.c#L1382 } else { VALUE *newptr; - long newsize = iv_index_tbl_newsize(&ivup); + uint32_t newsize = iv_index_tbl_newsize(&ivup); if (RBASIC(obj)->flags & ROBJECT_EMBED) { newptr = ALLOC_N(VALUE, newsize); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/