mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* re.c (rb_reg_prepare_re): fix SEGV by
/a/ =~ "aa".force_encoding("utf-16be"). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0c8106ded6
commit
3766eac339
2 changed files with 10 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed Jan 23 13:39:48 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* re.c (rb_reg_prepare_re): fix SEGV by
|
||||
/a/ =~ "aa".force_encoding("utf-16be").
|
||||
|
||||
Wed Jan 23 11:53:26 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (str_mod_check, str_nth, str_offset): consitfied.
|
||||
|
|
6
re.c
6
re.c
|
@ -955,7 +955,7 @@ rb_reg_prepare_re(VALUE re, VALUE str)
|
|||
|
||||
rb_reg_check(re);
|
||||
/* ignorecase status */
|
||||
if (rb_reg_fixed_encoding_p(re)) {
|
||||
if (rb_reg_fixed_encoding_p(re) || !rb_enc_str_asciicompat_p(str)) {
|
||||
if (ENCODING_GET(re) != rb_enc_get_index(str) &&
|
||||
rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) {
|
||||
rb_raise(rb_eArgError,
|
||||
|
@ -994,6 +994,10 @@ rb_reg_prepare_re(VALUE re, VALUE str)
|
|||
RREGEXP(re)->str, RREGEXP(re)->str + RREGEXP(re)->len, enc,
|
||||
&fixed_enc, err);
|
||||
|
||||
if (unescaped == Qnil) {
|
||||
rb_raise(rb_eArgError, "regexp preprocess failed: %s", err);
|
||||
}
|
||||
|
||||
r = onig_new(®2, (UChar* )RSTRING_PTR(unescaped),
|
||||
(UChar* )(RSTRING_PTR(unescaped) + RSTRING_LEN(unescaped)),
|
||||
reg->options, enc,
|
||||
|
|
Loading…
Reference in a new issue