From db1aa39ffcaa5b9f062639eb30c76959f4607a8e Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 13 Nov 2022 11:13:53 +0900 Subject: merge revision(s) 199b59f065ce6f1c13b8424f35a70c513523211b: [Backport #19116] Fix bug in array pack with shared strings If string literals are long and they become shared, we need to make them independent before we can write to them. [Bug #19116] --- pack.c | 1 + test/ruby/test_array.rb | 6 ++++++ 2 files changed, 7 insertions(+) --- test/ruby/test_array.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/ruby/test_array.rb') diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index a97a9c2558..ccbe85877f 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1294,6 +1294,12 @@ class TestArray < Test::Unit::TestCase =end end + def test_pack_with_buffer + n = [ 65, 66, 67 ] + str = "a" * 100 + assert_equal("aaaABC", n.pack("@3ccc", buffer: str.dup), "[Bug #19116]") + end + def test_pop a = @cls[ 'cat', 'dog' ] assert_equal('dog', a.pop) -- cgit v1.2.3