summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/string.c b/string.c
index cb7e86e84c..adc1c8d3c2 100644
--- a/string.c
+++ b/string.c
@@ -1288,17 +1288,20 @@ str_gsub(argc, argv, str, bang)
if (str_independent(str)) {
free(RSTRING(str)->ptr);
}
+ else {
+ RSTRING(str)->orig = 0;
+ }
}
else {
NEWOBJ(dup, struct RString);
OBJSETUP(dup, rb_cString, T_STRING);
OBJ_INFECT(dup, str);
str = (VALUE)dup;
+ dup->orig = 0;
}
RSTRING(str)->ptr = buf;
RSTRING(str)->len = len = bp - buf;
RSTRING(str)->ptr[len] = '\0';
- RSTRING(str)->orig = 0;
if (tainted) OBJ_TAINT(str);
return str;