From 9863b920b0efae02fd8f9a1080d5888521b44ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B0=8F=E7=99=BD?= <364772080@qq.com> Date: Fri, 19 Apr 2024 13:28:39 +0800 Subject: [PATCH] windows: Fix panic with some unicode characters (#10750) Fix #10749 Release Notes: - N/A --- crates/gpui/src/platform/windows/direct_write.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/platform/windows/direct_write.rs b/crates/gpui/src/platform/windows/direct_write.rs index 87b8921b43..0cfc0ac914 100644 --- a/crates/gpui/src/platform/windows/direct_write.rs +++ b/crates/gpui/src/platform/windows/direct_write.rs @@ -928,8 +928,11 @@ impl IDWriteTextRenderer_Impl for TextRenderer { ) -> windows::core::Result<()> { unsafe { let glyphrun = &*glyphrun; - let desc = &*glyphrundescription; let glyph_count = glyphrun.glyphCount as usize; + if glyph_count == 0 { + return Ok(()); + } + let desc = &*glyphrundescription; let utf16_length_per_glyph = desc.stringLength as usize / glyph_count; let context = &mut *(clientdrawingcontext as *const RendererContext as *mut RendererContext);