This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
radiance-sycl/vendor/patches/0001-unicode-reject-codepoints-above-U-10FFFF.patch
T
2026-10-04 12:02:41 +02:00

18 lines
931 B
Diff

--- a/src/unicode.cpp
+++ b/src/unicode.cpp
@@ -58,6 +58,14 @@
throw std::invalid_argument("invalid character");
}
auto result = ((utf8[offset + 0] & 0x07) << 18) | ((utf8[offset + 1] & 0x3f) << 12) | ((utf8[offset + 2] & 0x3f) << 6) | (utf8[offset + 3] & 0x3f);
+ // RADIANCE: lead bytes 0xF5..0xF7 decode above U+10FFFF, which unicode_cpt_to_utf8()
+ // then refuses with a throw that nothing catches -- so four arbitrary bytes in a prompt
+ // terminate the process. Rejecting here instead routes it through the invalid_argument
+ // that unicode_cpts_from_utf8() already turns into U+FFFD. Only the out-of-range case
+ // changes; every sequence upstream accepts still decodes to the same codepoint.
+ if (result > 0x10ffff) {
+ throw std::invalid_argument("invalid character");
+ }
offset += 4;
return result;
}