aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/string.c b/string.c
index af2354708e..e2f7fab1e6 100644
--- a/string.c
+++ b/string.c
@@ -2048,6 +2048,9 @@ str_gsub(argc, argv, str, bang)
if (iter) {
rb_match_busy(match);
val = rb_obj_as_string(rb_yield(rb_reg_nth_match(0, match)));
+ if (RSTRING(str)->ptr == buf) {
+ rb_raise(rb_eRuntimeError, "gsub reentered");
+ }
rb_backref_set(match);
}
else {