mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
Fix improper termlen fill in str_duplicate_setup_embed.
When term len != 1 (for example: Encoding::UTF32BE), term fill is wrong size.
This commit is contained in:
parent
9de66a8c51
commit
371a295e19
Notes:
git
2025-11-17 15:54:14 +00:00
4
string.c
4
string.c
@ -1935,8 +1935,8 @@ str_duplicate_setup_embed(VALUE klass, VALUE str, VALUE dup)
|
||||
long len = RSTRING_LEN(str);
|
||||
|
||||
RUBY_ASSERT(STR_EMBED_P(dup));
|
||||
RUBY_ASSERT(str_embed_capa(dup) >= len + 1);
|
||||
MEMCPY(RSTRING(dup)->as.embed.ary, RSTRING(str)->as.embed.ary, char, len + 1);
|
||||
RUBY_ASSERT(str_embed_capa(dup) >= len + TERM_LEN(str));
|
||||
MEMCPY(RSTRING(dup)->as.embed.ary, RSTRING(str)->as.embed.ary, char, len + TERM_LEN(str));
|
||||
STR_SET_LEN(dup, RSTRING_LEN(str));
|
||||
return str_duplicate_setup_encoding(str, dup, flags);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user