]> git.eshelyaron.com Git - emacs.git/commitdiff
w32: fail gracefully when using invalid glyphs on DWrite
authorCecilio Pardo <cpardo@imayhem.com>
Thu, 27 Mar 2025 12:26:00 +0000 (13:26 +0100)
committerEshel Yaron <me@eshelyaron.com>
Fri, 28 Mar 2025 16:17:25 +0000 (17:17 +0100)
* src/w32dwrite.c (text_extents_internal): Return false instead
of crashing with bad glyph indexes.  (Bug#77196)

(cherry picked from commit 33a46ff565296b491e808aa63d1dbaa2d994bbb5)

src/w32dwrite.c

index 4dc65b15db7a0a6b70fa23126403625ea25c6009..10af8545a1124524423b1375fd456dae3d382782 100644 (file)
@@ -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 ();