Skip to content

Commit

Permalink
FIX: READ/string crashes for UCS4 ("UTF-32") LE/BE files with a BOM
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Oldes committed Dec 18, 2018
1 parent 542d8dd commit 9190f1c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/s-unicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,7 @@ ConversionResult ConvertUTF8toUTF32 (
/*
***********************************************************************/
{
Trap0(RE_BAD_DECODE); // not yet supported
return 0;
}

Expand Down Expand Up @@ -946,9 +947,9 @@ ConversionResult ConvertUTF8toUTF32 (
else if (utf == -16 || utf == 16) {
size = Decode_UTF16((REBUNI*)Reset_Buffer(ser, len/2 + 1), bp, len, utf < 0, TRUE);
}
// else if (utf == -32 || utf == 32) {
// size = Decode_UTF32((REBUNI*)Reset_Buffer(ser, len/4 + 1), bp, len, utf < 0, TRUE);
// }
else if (utf == -32 || utf == 32) {
size = Decode_UTF32((REBUNI*)Reset_Buffer(ser, len/4 + 1), bp, len, utf < 0, TRUE);
}

if (size < 0) {
size = -size;
Expand Down

0 comments on commit 9190f1c

Please sign in to comment.