fix(win32 gui): avoid a panic on invalid utf-8

This commit is contained in:
CJ van den Berg 2025-01-14 13:08:27 +01:00
parent 27f256a7c5
commit 9cc5c9711b
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -359,7 +359,10 @@ fn generateGlyph(
grapheme_utf8: []const u8,
texture: *win32.ID3D11Texture2D,
) u32 {
const codepoint = std.unicode.wtf8Decode(grapheme_utf8) catch std.unicode.replacement_character;
const codepoint = if (std.unicode.utf8ValidateSlice(grapheme_utf8))
std.unicode.wtf8Decode(grapheme_utf8) catch std.unicode.replacement_character
else
std.unicode.replacement_character;
switch (glyph_index_cache.reserve(
global.glyph_cache_arena.allocator(),
codepoint,