summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
Diffstat (limited to 're.c')
-rw-r--r--re.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/re.c b/re.c
index 5e73ddbd8b..99759c93d9 100644
--- a/re.c
+++ b/re.c
@@ -637,7 +637,7 @@ rb_reg_search(re, str, pos, reverse)
if (result == -2) {
rb_reg_raise(RREGEXP(re)->str, RREGEXP(re)->len,
- "Stack overflow in regexp matcher", re);
+ "Stack overflow in regexp matcher", re);
}
if (result < 0) {
@@ -1001,7 +1001,10 @@ rb_reg_match(re, str)
{
int start;
- if (NIL_P(str)) return Qnil;
+ if (NIL_P(str)) {
+ rb_backref_set(Qnil);
+ return Qnil;
+ }
StringValue(str);
start = rb_reg_search(re, str, 0, 0);
if (start < 0) {
@@ -1017,8 +1020,10 @@ rb_reg_match2(re)
int start;
VALUE line = rb_lastline_get();
- if (TYPE(line) != T_STRING)
+ if (TYPE(line) != T_STRING) {
+ rb_backref_set(Qnil);
return Qnil;
+ }
start = rb_reg_search(re, line, 0, 0);
if (start < 0) {