summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2022-11-08 23:36:14 +0900
committerYusuke Endoh <mame@ruby-lang.org>2022-11-09 23:21:26 +0900
commit14845ab4ffccc317a08629f4503c87ee97621c0b (patch)
tree07a36a831c57fe8c96197ab32eb0bdda468c92b6 /regexec.c
parent537286d0bb5021afe188cfba6100772bb0285e06 (diff)
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`.
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/regexec.c b/regexec.c
index 94d03241a5..e8fffccd8b 100644
--- a/regexec.c
+++ b/regexec.c
@@ -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);