summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-22 10:04:47 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-22 10:04:47 +0000
commitbc65dbcdeb1922adcb7eb5cbeb176eb09475c3af (patch)
tree40ec2f63059c38dca953b49e0ba5ddfab0988a05 /variable.c
parent3738fe3333e614afba407e64aded6535a09856cc (diff)
downloadruby-bc65dbcdeb1922adcb7eb5cbeb176eb09475c3af.tar.gz
variable.c: fix implicit conversion
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c7
1 files 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);