aboutsummaryrefslogtreecommitdiffstats
path: root/re.c
diff options
context:
space:
mode:
Diffstat (limited to 're.c')
-rw-r--r--re.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/re.c b/re.c
index eae1ebd05b..4c473a8bb4 100644
--- a/re.c
+++ b/re.c
@@ -2856,13 +2856,10 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
}
}
+ if (!val) return str;
if (p < e) {
- if (!val) {
- val = rb_str_buf_new(e-p);
- }
rb_str_buf_cat(val, p, e-p);
}
- if (!val) return str;
rb_enc_associate(val, enc);
return val;