Skip to content

Commit

Permalink
* string.c (rb_str_shared_replace): make str noembed after free.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
akr committed Dec 13, 2007
1 parent 719841c commit 9595af4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
14 changes: 13 additions & 1 deletion .gdbinit
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,19 @@ define rp
((struct RString*)$arg0)->as.heap.ptr : \
((struct RString*)$arg0)->as.ary)
set print address on
printf " encoding:%d ", ($flags & (RUBY_FL_USER8|RUBY_FL_USER9|RUBY_FL_USER10|RUBY_FL_USER11)) >> RUBY_ENCODING_SHIFT
printf " bytesize:%d ", ($flags & RUBY_FL_USER1) ? \
((struct RString*)$arg0)->as.heap.len : \
(($flags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
if !($flags & RUBY_FL_USER1)
printf "(embed) "
end
if ($flags & RUBY_FL_USER2)
printf "(shared) "
end
if ($flags & RUBY_FL_USER3)
printf "(assoc) "
end
printf "encoding:%d ", ($flags & (RUBY_FL_USER8|RUBY_FL_USER9|RUBY_FL_USER10|RUBY_FL_USER11)) >> RUBY_ENCODING_SHIFT
if ($flags & (RUBY_FL_USER12|RUBY_FL_USER13)) == 0
printf "coderange:unknown "
else
Expand Down
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Thu Dec 13 20:31:28 2007 Tanaka Akira <[email protected]>

* string.c (rb_str_shared_replace): make str noembed after free.

Thu Dec 13 20:09:09 2007 Tanaka Akira <[email protected]>

* eval.c (rb_protect): restore root_jmpbuf to avoid SEGV by
Expand Down
2 changes: 1 addition & 1 deletion string.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,10 @@ rb_str_shared_replace(VALUE str, VALUE str2)
STR_SET_EMBED_LEN(str, RSTRING_LEN(str2));
return;
}
STR_SET_NOEMBED(str);
if (!STR_SHARED_P(str) && !STR_EMBED_P(str)) {
free(RSTRING_PTR(str));
}
STR_SET_NOEMBED(str);
STR_UNSET_NOCAPA(str);
RSTRING(str)->as.heap.ptr = RSTRING_PTR(str2);
RSTRING(str)->as.heap.len = RSTRING_LEN(str2);
Expand Down
3 changes: 3 additions & 0 deletions test/ruby/test_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,9 @@ def test_succ!
a = S("**")
assert_equal(S("*+"), a.succ!)
assert_equal(S("*+"), a)

assert_equal("aaaaaaaaaaaa", "zzzzzzzzzzz".succ!)
assert_equal("aaaaaaaaaaaaaaaaaaaaaaaa", "zzzzzzzzzzzzzzzzzzzzzzz".succ!)
end

def test_sum
Expand Down

0 comments on commit 9595af4

Please sign in to comment.