mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Ensure that the table size for CACHE_MATCH fits with int
Currently, the keys for CACHE_MATCH are handled as an `int` type. So we should make sure the table size are smaller than the range of `int`.
This commit is contained in:
parent
537286d0bb
commit
14845ab4ff
1 changed files with 1 additions and 1 deletions
|
@ -3842,7 +3842,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
|
|||
size_t len = (end - str) + 1;
|
||||
size_t match_cache_size8 = (size_t)msa->num_cache_opcode * len;
|
||||
/* overflow check */
|
||||
if (match_cache_size8 / len != (size_t)msa->num_cache_opcode) {
|
||||
if (match_cache_size8 >= INT_MAX_LIMIT) {
|
||||
return ONIGERR_MEMORY;
|
||||
}
|
||||
size_t match_cache_size = (match_cache_size8 >> 3) + (match_cache_size8 & 7 ? 1 : 0);
|
||||
|
|
Loading…
Reference in a new issue