Skip to content

Commit

Permalink
Fix bug not freeing onigmo region on mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
seven1m committed Jul 6, 2024
1 parent 2212280 commit fd71f8b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/string_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,9 +811,9 @@ nat_int_t StringObject::index_int(Env *env, Value needle, size_t byte_start) {
return -1;

OnigRegion *region = onig_region_new();
// FIXME: need to free with onig_region_free
int result = needle->as_regexp()->search(env, this, byte_start, region, ONIG_OPTION_NONE);
if (result == ONIG_MISMATCH) {
onig_region_free(region, true);
env->caller()->set_last_match(nullptr);
return -1;
}
Expand Down

0 comments on commit fd71f8b

Please sign in to comment.