Skip to content

Commit bdaca6a

Browse files
committed
FIX: Crash when loading specially crafted binary
fixes: Oldes/Rebol-issues#2435
1 parent 6121a84 commit bdaca6a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/core/s-crc.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,11 @@ static REBCNT *CRC32_Table = 0;
169169

170170
for (; ulen > 0; str++, ulen--) {
171171
n = *str;
172-
if (n > 127 && NZ(m = Decode_UTF8_Char(&str, &ulen))) n = m; // mods str, ulen
172+
if (n > 127) {
173+
m = Decode_UTF8_Char(&str, &ulen); // mods str, ulen
174+
if (!m) Trap0(RE_INVALID_CHARS);
175+
n = m;
176+
}
173177
if (n < UNICODE_CASES) n = LO_CASE(n);
174178
n = (REBYTE)((hash >> CRCSHIFTS) ^ (REBYTE)n); // drop upper 8 bits
175179
hash = MASK_CRC(hash << 8) ^ (REBINT)CRC24_Table[n];

0 commit comments

Comments
 (0)