summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-21 10:51:52 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-21 10:51:52 (GMT)
commit2d12151a686ccc71f62ae53f025605191342417c (patch)
treec30e4b74f2eff530ef1dcf61e3bbfe3fc0eb2459 /re.c
parent516e463aaf0850b21630e094e42ad0bb543c8c81 (diff)
re.c: RMatch::regexp can be nil
* re.c (match_aref): RMatch::regexp is Qnil after matching by a string since r45451. [ruby-core:68209] [Bug #10877] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/re.c b/re.c
index 1f88d60..7e789f5 100644
--- a/re.c
+++ b/re.c
@@ -1787,7 +1787,7 @@ name_to_backref_error(VALUE name)
static VALUE
match_aref(int argc, VALUE *argv, VALUE match)
{
- VALUE idx, rest;
+ VALUE idx, rest, re;
match_check(match);
rb_scan_args(argc, argv, "11", &idx, &rest);
@@ -1808,7 +1808,8 @@ match_aref(int argc, VALUE *argv, VALUE match)
/* fall through */
case T_STRING:
p = StringValuePtr(idx);
- if (!rb_enc_compatible(RREGEXP(RMATCH(match)->regexp)->src, idx) ||
+ re = RMATCH(match)->regexp;
+ if (NIL_P(re) || !rb_enc_compatible(RREGEXP(re)->src, idx) ||
(num = name_to_backref_number(RMATCH_REGS(match), RMATCH(match)->regexp,
p, p + RSTRING_LEN(idx))) < 1) {
name_to_backref_error(idx);