aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_string.rb
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2017-11-12 17:09:59 +0900
committerKazuki Yamaguchi <k@rhe.jp>2017-11-12 20:41:25 +0900
commit8e5f487d86f398de53db1a297a367448f75066f7 (patch)
tree869b311b913d41187963c89bcdd80ab107265420 /test/ruby/test_string.rb
parent80dba1a0e4ffdeb31a2b9eace7279fffd1c183f9 (diff)
downloadruby-work2.tar.gz
string.c: fix memory leak in rb_str_change_terminator_length()work2
str_make_independent_expand() cannot be used for a String that has its own buffer.
Diffstat (limited to 'test/ruby/test_string.rb')
-rw-r--r--test/ruby/test_string.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 7dd76f76f7..c53668ea61 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -2859,6 +2859,17 @@ CODE
assert_equal(Encoding::UTF_8, k.encoding, '[ruby-dev:39068]')
end
+ def test_force_encoding_changing_terminator_length
+ assert_no_memory_leak([], 's0 = "x" * 65535', <<~'end;')
+ 1_000.times {
+ # Allocate its own buffer of (65535+1) bytes
+ s = s0.b; s.setbyte(0, 0)
+ # Expand it to (65535+4) bytes
+ s.force_encoding("UTF-32LE")
+ }
+ end;
+ end
+
def test_ascii_incomat_inspect
bug4081 = '[ruby-core:33283]'
[Encoding::UTF_16LE, Encoding::UTF_16BE,