summaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-01-30 08:02:30 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-01-30 08:02:30 +0000
commit8a75e12370dee38b06a6ed62beec0a12ab810840 (patch)
tree359efb2484070f2a3cca41ec076a66936acc4086 /string.c
parentcaab7716ae8f3939ffed7a748b21fc343c851e1e (diff)
downloadruby-8a75e12370dee38b06a6ed62beec0a12ab810840.tar.gz
ruby-8a75e12370dee38b06a6ed62beec0a12ab810840.tar.xz
ruby-8a75e12370dee38b06a6ed62beec0a12ab810840.zip
* string.c (rb_str_sub_bang): calling rb_str_modify() should be just
before actually modifying the string. fixed: [ruby-dev:30211] (originally reported by zunda) git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@11598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/string.c b/string.c
index 7a5c7b45a..7a27af8d7 100644
--- a/string.c
+++ b/string.c
@@ -2027,7 +2027,6 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
pat = get_pat(argv[0], 1);
if (rb_reg_search(pat, str, 0, 0) >= 0) {
- rb_str_modify(str);
match = rb_backref_get();
regs = RMATCH(match)->regs;
@@ -2043,6 +2042,7 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
else {
repl = rb_reg_regsub(repl, str, regs, pat);
}
+ rb_str_modify(str);
if (OBJ_TAINTED(repl)) tainted = 1;
plen = END(0) - BEG(0);
if (RSTRING_LEN(repl) > plen) {