mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 14:38:13 +02:00
[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.
This commit is contained in:
parent
af392f7e45
commit
86d6a48952
1 changed files with 10 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue