summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2022-01-06 13:32:59 -0500
committerPeter Zhu <peter@peterzhu.ca>2022-01-06 14:33:35 -0500
commit44368b5f8bc21e19fa06a0fc0625923fc41293e6 (patch)
tree50cda3309ca14c6fa914a74d24b284e3a562ecae /string.c
parentee4784c06e991c605df31ab520e6b09c0ebc1e9e (diff)
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.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5399
Diffstat (limited to 'string.c')
-rw-r--r--string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/string.c b/string.c
index cdb8658d7f..5b3c7cd57b 100644
--- a/string.c
+++ b/string.c
@@ -3186,8 +3186,8 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,
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;