diff options
author | Nobuyoshi Nakada <[email protected]> | 2024-11-26 11:05:16 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2024-11-26 11:46:34 +0900 |
commit | 6b4f8945d600168bf530d21395da8293fbd5e8ba (patch) | |
tree | 00423c31613b2b7b3ce91ed7b745f67ebbd77944 /string.c | |
parent | 02b70256b5171d4b85ea7eeab836d3d7cfb3dbfc (diff) |
Many of Oniguruma functions need valid encoding strings
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12169
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -3076,7 +3076,8 @@ rb_str_subpos(VALUE str, long beg, long *lenp) } if (beg < 0) { if (len > -beg) len = -beg; - if (-beg * rb_enc_mbmaxlen(enc) < blen / 8) { + if ((ENC_CODERANGE(str) == ENC_CODERANGE_VALID) && + (-beg * rb_enc_mbmaxlen(enc) < blen / 8)) { beg = -beg; while (beg-- > len && (e = rb_enc_prev_char(s, e, e, enc)) != 0); p = e; |