summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
Diffstat (limited to 're.c')
-rw-r--r--re.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/re.c b/re.c
index db3f04ad04..15d5668e33 100644
--- a/re.c
+++ b/re.c
@@ -2146,7 +2146,8 @@ reg_match_pos(VALUE re, VALUE *strp, long pos)
*strp = str = reg_operand(str, Qtrue);
if (pos != 0) {
if (pos < 0) {
- pos += RSTRING_LEN(str);
+ VALUE l = rb_str_length(str);
+ pos += NUM2INT(l);
if (pos < 0) {
return pos;
}