[pango/pango2: 78/84] hbfamily: Unset face families




commit 330e6b676e1790a87a304dc3d7b4f89779a7e995
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 11 11:42:08 2022 -0400

    hbfamily: Unset face families
    
    Face objects may outlive their families.
    Make sure to not leave dangling pointers
    behind when that happens.

 pango/pango-hbfamily.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/pango/pango-hbfamily.c b/pango/pango-hbfamily.c
index 06938f4c7..ea11ef9f7 100644
--- a/pango/pango-hbfamily.c
+++ b/pango/pango-hbfamily.c
@@ -133,6 +133,12 @@ pango_hb_family_finalize (GObject *object)
 {
   PangoHbFamily *self = PANGO_HB_FAMILY (object);
 
+  for (int i = 0; i < self->faces->len; i++)
+    {
+      PangoHbFace *face = g_ptr_array_index (self->faces, i);
+      ((CommonFace *)face)->family = NULL;
+    }
+
   g_ptr_array_unref (self->faces);
 
   G_OBJECT_CLASS (pango_hb_family_parent_class)->finalize (object);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]