Skip to content

Commit 28a572f

Browse files
committed
Fix bug when slicing a string with broken encoding
Commit aa2a428 introduced a bug where non-embedded string slices copied the encoding of the original string. If the original string had a broken encoding but the slice has valid encoding, then the slice would be incorrectly marked as broken encoding.
1 parent 6f8d17e commit 28a572f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

string.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,6 +2811,7 @@ str_subseq(VALUE str, long beg, long len)
28112811
}
28122812
else {
28132813
str2 = str_new_shared(rb_cString, str);
2814+
ENC_CODERANGE_CLEAR(str2);
28142815
RSTRING(str2)->as.heap.ptr += beg;
28152816
if (RSTRING(str2)->as.heap.len > len) {
28162817
RSTRING(str2)->as.heap.len = len;

0 commit comments

Comments
 (0)