ruby-changes:70771
From: Peter <ko1@a...>
Date: Fri, 7 Jan 2022 04:33:50 +0900 (JST)
Subject: [ruby-changes:70771] 44368b5f8b (master): Set encoding before concatenating to string
https://git.ruby-lang.org/ruby.git/commit/?id=44368b5f8b From 44368b5f8bc21e19fa06a0fc0625923fc41293e6 Mon Sep 17 00:00:00 2001 From: Peter Zhu <peter@p...> Date: Thu, 6 Jan 2022 13:32:59 -0500 Subject: Set encoding before concatenating to string If we set encoding after the call to rb_str_buf_cat, then rb_str_buf_cat will not set the correct terminator length. --- string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/string.c b/string.c index cdb8658d7f4..5b3c7cd57b6 100644 --- a/string.c +++ b/string.c @@ -3186,8 +3186,8 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len, https://github.com/ruby/ruby/blob/trunk/string.c#L3186 if (len == 0) return str; if (RSTRING_LEN(str) == 0) { - rb_str_buf_cat(str, ptr, len); ENCODING_CODERANGE_SET(str, ptr_encindex, ptr_cr); + rb_str_buf_cat(str, ptr, len); return str; } goto incompatible; -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/