From: Behdad Esfahbod Date: Fri, 2 Jan 2009 07:00:36 +0000 (+0000) Subject: Fix possible reference leak when fallback is disabled. X-Git-Tag: 1.23.0~55 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=50d61fa3b2f74758be0ee234861c4ad20f2d2294;p=platform%2Fupstream%2Fpango.git Fix possible reference leak when fallback is disabled. 2009-01-02 Behdad Esfahbod * pango/pango-context.c (shaper_font_element_destroy), (get_shaper_font_cache), (shaper_font_cache_insert), (get_shaper_and_font_foreach), (itemize_state_process_run): Fix possible reference leak when fallback is disabled. svn path=/trunk/; revision=2774 --- diff --git a/ChangeLog b/ChangeLog index 7efe090..2537611 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-01-02 Behdad Esfahbod + + * pango/pango-context.c (shaper_font_element_destroy), + (get_shaper_font_cache), (shaper_font_cache_insert), + (get_shaper_and_font_foreach), (itemize_state_process_run): + Fix possible reference leak when fallback is disabled. + 2008-12-26 Behdad Esfahbod Bug 565644 – Maybe pango_font_descriptions_free is deprecated diff --git a/pango/pango-context.c b/pango/pango-context.c index f6cc2b7..4ede1ad 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -577,6 +577,8 @@ shaper_font_cache_destroy (ShaperFontCache *cache) static void shaper_font_element_destroy (ShaperFontElement *element) { + if (element->shape_engine) + g_object_unref (element->shape_engine); if (element->font) g_object_unref (element->font); g_slice_free (ShaperFontElement, element); @@ -588,7 +590,7 @@ get_shaper_font_cache (PangoFontset *fontset) ShaperFontCache *cache; static GQuark cache_quark = 0; - if (!cache_quark) + if (G_UNLIKELY (!cache_quark)) cache_quark = g_quark_from_static_string ("pango-shaper-font-cache"); cache = g_object_get_qdata (G_OBJECT (fontset), cache_quark); @@ -632,8 +634,8 @@ shaper_font_cache_insert (ShaperFontCache *cache, PangoFont *font) { ShaperFontElement *element = g_slice_new (ShaperFontElement); - element->shape_engine = shape_engine; - element->font = font; + element->shape_engine = shape_engine ? g_object_ref (shape_engine) : NULL; + element->font = font ? g_object_ref (font) : NULL; g_hash_table_insert (cache->hash, GUINT_TO_POINTER (wc), element); } @@ -1075,7 +1077,7 @@ get_shaper_and_font_foreach (PangoFontset *fontset G_GNUC_UNUSED, if (level != PANGO_COVERAGE_NONE) { info->shape_engine = engine; - info->font = g_object_ref (font); + info->font = font; return TRUE; } } @@ -1384,7 +1386,8 @@ itemize_state_process_run (ItemizeState *state) else what = "nothing (oops!)"; - g_warning ("failed to find shape engine, expect ugly output. engine-type='%s', script='%s'", + g_warning ("failed to find %s, expect ugly output. engine-type='%s', script='%s'", + what, pango_font_map_get_shape_engine_type (fontmap), script_name);