Closed masahino closed 2 years ago
I use latest version of mruby(6b2f08d).
Hmm, can't repro
On my environment(tried on Mac and Ubuntu), mrb_str_new is called with len = -3 at str_substr. https://github.com/mattn/mruby-onig-regexp/blob/76087d150d12f167e95ae10d326099b352cf3d18/src/mruby_onig_regexp.c#L105
This is because reg->end[0] = 4 in match_data_post_match, but I am not sure if this is the correct behavior. https://github.com/mattn/mruby-onig-regexp/blob/76087d150d12f167e95ae10d326099b352cf3d18/src/mruby_onig_regexp.c#L646
How about checking len as follows?
https://github.com/masahino/mruby-onig-regexp/commit/25b152264cd4dfac84aa39e5fbb428ec84b95e6a
Looks good. Could you please send me PR?
Segmentation fault occurs in the following test when MRB_UTF8_STRING is defined.
assert_raise(ArgumentError) { "\xf0".gsub(/[^a]/,"X") }