diff options
-rw-r--r-- | pack.c | 5 | ||||
-rw-r--r-- | test/ruby/test_array.rb | 6 | ||||
-rw-r--r-- | version.h | 4 |
3 files changed, 11 insertions, 4 deletions
@@ -212,12 +212,13 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer) pend = p + RSTRING_LEN(fmt); if (NIL_P(buffer)) { - res = rb_str_buf_new(0); + res = rb_str_buf_new(0); } else { if (!RB_TYPE_P(buffer, T_STRING)) rb_raise(rb_eTypeError, "buffer must be String, not %s", rb_obj_classname(buffer)); - res = buffer; + rb_str_modify(buffer); + res = buffer; } idx = 0; 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) @@ -11,11 +11,11 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 3 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 177 +#define RUBY_PATCHLEVEL 178 #define RUBY_RELEASE_YEAR 2022 #define RUBY_RELEASE_MONTH 11 -#define RUBY_RELEASE_DAY 5 +#define RUBY_RELEASE_DAY 13 #include "ruby/version.h" |