1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@11598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2007-01-30 08:02:30 +00:00
parent 8418ea8bb8
commit 2fc900dac8
2 changed files with 7 additions and 1 deletions

View file

@ -1,3 +1,9 @@
Tue Jan 30 17:01:21 2007 NAKAMURA Usaku <usa@ruby-lang.org>
* 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)
Tue Jan 30 13:24:06 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* numeric.c (int_pred): add Integer#pred corresponding

View file

@ -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) {