Skip to content

Commit 9190f1c

Browse files
committed
FIX: READ/string crashes for UCS4 ("UTF-32") LE/BE files with a BOM
This is just a temporary fix preventing a crash and using script exception instead: ``` >> to-string #{0000FEFF000000E4000000F6000000FC0000000A} ** Script error: missing or unsupported encoding marker ** Where: to to-string ** Near: to string! :value ``` Related issue: metaeducation/rebol-issues#2186
1 parent 542d8dd commit 9190f1c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/core/s-unicode.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@ ConversionResult ConvertUTF8toUTF32 (
912912
/*
913913
***********************************************************************/
914914
{
915+
Trap0(RE_BAD_DECODE); // not yet supported
915916
return 0;
916917
}
917918

@@ -946,9 +947,9 @@ ConversionResult ConvertUTF8toUTF32 (
946947
else if (utf == -16 || utf == 16) {
947948
size = Decode_UTF16((REBUNI*)Reset_Buffer(ser, len/2 + 1), bp, len, utf < 0, TRUE);
948949
}
949-
// else if (utf == -32 || utf == 32) {
950-
// size = Decode_UTF32((REBUNI*)Reset_Buffer(ser, len/4 + 1), bp, len, utf < 0, TRUE);
951-
// }
950+
else if (utf == -32 || utf == 32) {
951+
size = Decode_UTF32((REBUNI*)Reset_Buffer(ser, len/4 + 1), bp, len, utf < 0, TRUE);
952+
}
952953

953954
if (size < 0) {
954955
size = -size;

0 commit comments

Comments
 (0)