[PATCH] check for hb_shape_full failure
authorCaolán McNamara <caolan.mcnamara@collabora.com>
Wed, 6 May 2026 14:37:30 +0000 (15:37 +0100)
committerRene Engelhard <rene@debian.org>
Sat, 6 Jun 2026 20:12:08 +0000 (22:12 +0200)
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I5fafcb7d592fb4c9091cb2bab64cb6ac47462d71
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/2102
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 22c19be8fae977a90f83a82d8acccd0b46c7cf20)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204946
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Gbp-Pq: Name check-for-hb_shape_full-failure.diff

vcl/source/gdi/CommonSalLayout.cxx

index b40851a2f18cab2785e491ae94e65b0f1e42bcd2..dc7dd332ceff6457184202c03e3da28cf6afdd1e 100644 (file)
@@ -203,10 +203,11 @@ public:
         // The shapers that we want HarfBuzz to use, in the order of
         // preference.
         const char* const pHbShapers[] = { "graphite2", "ot", "fallback", nullptr };
-        bool ok
-            = hb_shape_full(pHbFont, m_pHbBuffer, maFeatures.data(), maFeatures.size(), pHbShapers);
-        assert(ok);
-        (void)ok;
+        if (!hb_shape_full(pHbFont, m_pHbBuffer, maFeatures.data(), maFeatures.size(), pHbShapers))
+        {
+            SAL_WARN("vcl.harfbuzz", "hb_shape_full failed");
+            hb_buffer_set_length(m_pHbBuffer, 0);
+        }
 
         int nRunGlyphCount = hb_buffer_get_length(m_pHbBuffer);
         hb_glyph_info_t* pHbGlyphInfos = hb_buffer_get_glyph_infos(m_pHbBuffer, nullptr);
@@ -595,9 +596,11 @@ bool GenericSalLayout::LayoutText(vcl::text::ImplLayoutArgs& rArgs, const SalLay
             // The shapers that we want HarfBuzz to use, in the order of
             // preference.
             const char*const pHbShapers[] = { "graphite2", "ot", "fallback", nullptr };
-            bool ok = hb_shape_full(pHbFont, pHbBuffer, maFeatures.data(), maFeatures.size(), pHbShapers);
-            assert(ok);
-            (void) ok;
+            if (!hb_shape_full(pHbFont, pHbBuffer, maFeatures.data(), maFeatures.size(), pHbShapers))
+            {
+                SAL_WARN("vcl.harfbuzz", "hb_shape_full failed");
+                hb_buffer_set_length(pHbBuffer, 0);
+            }
 
             // Populate glyph cluster remapping data
             stClusterMapper.ShapeSubRun(pStr, nLength, aSubRun, pHbFont, maFeatures, oHbLanguage);