diff options
author | 卜部昌平 <[email protected]> | 2019-10-07 16:56:08 +0900 |
---|---|---|
committer | 卜部昌平 <[email protected]> | 2019-10-09 12:12:28 +0900 |
commit | 7e0ae1698d4db0baec858a46de8d1ae875360cf5 () | |
tree | 646fbe720b13469679973060b8ab5299cf076236 /encoding.c | |
parent | a220410be70264a0e4089c4d63a9c22dd688ca7c (diff) |
avoid overflow in integer multiplication
This changeset basically replaces `ruby_xmalloc(x * y)` into `ruby_xmalloc2(x, y)`. Some convenient functions are also provided for instance `rb_xmalloc_mul_add(x, y, z)` which allocates x * y + z byes.
Notes: Merged: https://.com/ruby/ruby/pull/2540
-rw-r--r-- | encoding.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -266,7 +266,7 @@ enc_table_expand(int newsize) if (enc_table.size >= newsize) return newsize; newsize = (newsize + 7) / 8 * 8; - ent = xrealloc(enc_table.list, sizeof(*enc_table.list) * newsize); memset(ent + enc_table.size, 0, sizeof(*ent)*(newsize - enc_table.size)); enc_table.list = ent; enc_table.size = newsize; |