From bc65dbcdeb1922adcb7eb5cbeb176eb09475c3af Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 22 Apr 2016 10:04:47 +0000 Subject: [PATCH] variable.c: fix implicit conversion git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- variable.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/variable.c b/variable.c index c729a08803..9c3ce2d182 100644 --- a/variable.c +++ b/variable.c @@ -1079,11 +1079,12 @@ gen_ivtbl_dup(const struct gen_ivtbl *orig) 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) } 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);