diff --git a/.gdbinit b/.gdbinit index f91ef63d06..66a4acbbe0 100644 --- a/.gdbinit +++ b/.gdbinit @@ -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 diff --git a/ChangeLog b/ChangeLog index 6772164b4b..e60148b86c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Dec 13 20:31:28 2007 Tanaka Akira + + * string.c (rb_str_shared_replace): make str noembed after free. + Thu Dec 13 20:09:09 2007 Tanaka Akira * eval.c (rb_protect): restore root_jmpbuf to avoid SEGV by diff --git a/string.c b/string.c index 2ab8082817..edbc8d6d6e 100644 --- a/string.c +++ b/string.c @@ -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); diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 5657197834..b2d8ab8a09 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1091,6 +1091,9 @@ class TestString < Test::Unit::TestCase 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