diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2012-10-15 20:02:56 -0500 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2012-11-07 10:59:04 -0800 |
commit | 16169eec0dcb3d32ae456c5a16c82056e35dc28b (patch) | |
tree | 7e8bb363edcd0f8897984e3ccd54793a0d9ef028 | |
parent | 0336db39ebbd94a2ba53370e188b40dcab6b9a32 (diff) | |
download | pango-16169eec0dcb3d32ae456c5a16c82056e35dc28b.tar.gz |
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.
-rw-r--r-- | pango/pangocairo-font.c | 10 |
1 files 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 |