From 16169eec0dcb3d32ae456c5a16c82056e35dc28b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 15 Oct 2012 20:02:56 -0500 Subject: Don't dispose cf_priv->data when we are done with it Is racy, can cause crashes when one thread disposes it while another is still using it. --- pango/pangocairo-font.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c index 57b6dd1e..67fdcf15 100644 --- a/pango/pangocairo-font.c +++ b/pango/pangocairo-font.c @@ -67,10 +67,7 @@ _pango_cairo_font_private_get_scaled_font (PangoCairoFontPrivate *cf_priv) retry: scaled_font = g_atomic_pointer_get (&cf_priv->scaled_font); - /* The case of scaled_font == NULL && data == NULL happens when we tried to - * create it, and failed before. */ - if (G_UNLIKELY (!scaled_font) && - ((data = g_atomic_pointer_get (&cf_priv->data)) != NULL)) + if (G_UNLIKELY (!scaled_font)) { cairo_font_face_t *font_face; font_face = (* PANGO_CAIRO_FONT_GET_IFACE (cf_priv->cfont)->create_font_face) (cf_priv->cfont); @@ -89,9 +86,6 @@ retry: goto retry; } - if (g_atomic_pointer_compare_and_exchange (&cf_priv->data, data, NULL)) - _pango_cairo_font_private_scaled_font_data_destroy (data); - if (G_UNLIKELY (!scaled_font || cairo_scaled_font_status (scaled_font) != CAIRO_STATUS_SUCCESS)) { cairo_scaled_font_t *scaled_font = cf_priv->scaled_font; @@ -586,7 +580,7 @@ _pango_cairo_font_private_initialize (PangoCairoFontPrivate *cf_priv, cf_priv->cfont = cfont; cf_priv->gravity = gravity; - cf_priv->data = _pango_cairo_font_private_scaled_font_data_create (); + cf_priv->data = _pango_cairo_font_private_scaled_font_data_create (); /* first apply gravity rotation, then font_matrix, such that * vertical italic text comes out "correct". we don't do anything -- cgit v1.2.1