From: Cecilio Pardo Date: Thu, 27 Mar 2025 12:26:00 +0000 (+0100) Subject: w32: fail gracefully when using invalid glyphs on DWrite X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d7ee518ac0194ed2b2548012185924ae4f48cb8b;p=emacs.git w32: fail gracefully when using invalid glyphs on DWrite * src/w32dwrite.c (text_extents_internal): Return false instead of crashing with bad glyph indexes. (Bug#77196) (cherry picked from commit 33a46ff565296b491e808aa63d1dbaa2d994bbb5) --- diff --git a/src/w32dwrite.c b/src/w32dwrite.c index 4dc65b15db7..10af8545a11 100644 --- a/src/w32dwrite.c +++ b/src/w32dwrite.c @@ -610,6 +610,14 @@ text_extents_internal (IDWriteFontFace *dwrite_font_face, nglyphs, gmetrics, false); + + /* E_INVALIDARG means some of the glyphs index is out of bounds for the font. */ + if (hr == E_INVALIDARG) + { + SAFE_FREE (); + return false; + } + if (!verify_hr (hr, "Failed to GetGdiCompatibleGlyphMetrics")) { SAFE_FREE ();