summaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-28 12:25:45 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-28 12:25:45 +0000
commit2a592c65a31ed0b8da81a9ce0ad375d5c17aa8b9 (patch)
tree6ef0adfb397248308136bd096c7dc3241b782809 /string.c
parent436defcc87afef2a730847c1ca54649bbbda1dcd (diff)
downloadruby-2a592c65a31ed0b8da81a9ce0ad375d5c17aa8b9.tar.gz
ruby-2a592c65a31ed0b8da81a9ce0ad375d5c17aa8b9.tar.xz
ruby-2a592c65a31ed0b8da81a9ce0ad375d5c17aa8b9.zip
* include/ruby/ruby.h (struct RRegexp): new field usecnt. replace
str and len by src. * gc.c (gc_mark_children): mark src field of regexp. (obj_free): don't free str field. * re.c (REG_BUSY): removed. (rb_reg_initialize): prohibit re-initialize regexp. (rb_reg_search): use usecnt to prevent freeing regexp currently using. this prevents SEGV by: r = /\A((a.)*(a.)*)*b/ r =~ "ab" + "\xc2\xa1".force_encoding("euc-jp") t = Thread.new { r =~ "ab"*8 + "\xc2\xa1".force_encoding("utf-8")} sleep 0.2 r =~ "ab"*8 + "\xc2\xa1".force_encoding("euc-jp") git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@17635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/string.c b/string.c
index 4746842f5..49f3ba945 100644
--- a/string.c
+++ b/string.c
@@ -2247,7 +2247,7 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str)
switch (TYPE(sub)) {
case T_REGEXP:
/* enc = rb_get_check(str, sub); */
- if (RREGEXP(sub)->len) {
+ if (!RREGEXP(sub)->ptr || RREGEXP_SRC_LEN(sub)) {
pos = rb_reg_adjust_startpos(sub, str, pos, 1);
pos = rb_reg_search(sub, str, pos, 1);
pos = rb_str_sublen(str, pos);