summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorYusuke Endoh <[email protected]>2022-11-08 18:09:57 +0900
committerYusuke Endoh <[email protected]>2022-11-09 23:21:26 +0900
commitff5dba831910c91e293220b652be868e9cfdc8e1 ()
tree159b71f5fcbbc0e4771e0e8f4fca3b000aedbb58 /regexec.c
parenta1c1fc558a0ee791e91a66cae5c9515679890339 (diff)
Return ONIGERR_MEMORY if it fails to allocate memory for cache_match_opt
-rw-r--r--regexec.c16
1 files changed, 9 insertions, 7 deletions
@@ -3833,20 +3833,22 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (msa->cache_index_table == NULL) {
OnigCacheIndex *table = (OnigCacheIndex *)xmalloc(table_size * sizeof(OnigCacheIndex));
if (table == NULL) {
- msa->enable_cache_match_opt = 0;
- goto fail_match_cache_opt;
}
init_cache_index_table(reg, table);
msa->cache_index_table = table;
msa->num_cache_table = table_size;
}
- // TODO: check arithemetic overflow.
- int match_cache_size8 = msa->num_cache_opcode * ((int)(end - str) + 1);
- int match_cache_size = (match_cache_size8 >> 3) + (match_cache_size8 & 7 ? 1 : 0);
msa->match_cache = (uint8_t*)xmalloc(match_cache_size * sizeof(uint8_t));
if (msa->match_cache == NULL) {
- msa->enable_cache_match_opt = 0;
- goto fail_match_cache_opt;
}
xmemset(msa->match_cache, 0, match_cache_size * sizeof(uint8_t));
}