From 33a46ff565296b491e808aa63d1dbaa2d994bbb5 Mon Sep 17 00:00:00 2001 From: Cecilio Pardo Date: Thu, 27 Mar 2025 13:26:00 +0100 Subject: [PATCH] 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) --- src/w32dwrite.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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 ();