diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-08-06 23:39:21 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-08-06 23:47:40 +0100 |
commit | 86d6a489527d125e739aa5a6d17893bb44977010 (patch) | |
tree | 112c8a139c9e7c9544595bf299382f6f2644141a /util | |
parent | af392f7e45edcbf101ca7c91fc1ee372d283e8b9 (diff) |
[script] Check for failure to store the glyph cache
If we fail to add the glyph cache (presumably because the font is in
error) do not leak the allocation. As this occurs for every single glyph
string, the leak can grow very quickly and mask the original bug.
Diffstat (limited to 'util')
-rw-r--r-- | util/cairo-script/cairo-script-operators.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c index 81bbe7647..5247682fb 100644 --- a/util/cairo-script/cairo-script-operators.c +++ b/util/cairo-script/cairo-script-operators.c @@ -2354,9 +2354,10 @@ _glyph_string (csi_t *ctx, double x,y; csi_integer_t nglyphs, i, j; struct glyph_advance_cache *cache; + cairo_status_t status; cache = cairo_scaled_font_get_user_data (scaled_font, - (cairo_user_data_key_t *) &_glyph_string); + (cairo_user_data_key_t *) ctx); if (cache == NULL) { cache = _csi_alloc (ctx, sizeof (*cache)); if (cache == NULL) @@ -2366,9 +2367,14 @@ _glyph_string (csi_t *ctx, memset (cache->have_glyph_advance, 0xff, sizeof (cache->have_glyph_advance)); - cairo_scaled_font_set_user_data (scaled_font, - (cairo_user_data_key_t *) &_glyph_string, - cache, glyph_advance_cache_destroy); + status = cairo_scaled_font_set_user_data (scaled_font, + (cairo_user_data_key_t *) ctx, + cache, + glyph_advance_cache_destroy); + if (status) { + _csi_free (ctx, cache); + return -1; + } } nglyphs = 0; |