From 955b5de4ba103fb115ec0b45f9b59eb2628ca3dd Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 10 Mar 2014 16:38:54 +0000 Subject: [PATCH] sna/glyph: Release the pixman glyph cache along the error paths If we lock the glyph cache and then hit an error, we must make sure we release our lock. An easy way would be not to lock when we may err. Signed-off-by: Chris Wilson --- src/sna/sna_glyphs.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c index c72c5e5d..eca0df0e 100644 --- a/src/sna/sna_glyphs.c +++ b/src/sna/sna_glyphs.c @@ -1147,14 +1147,11 @@ glyphs_via_mask(struct sna *sna, memset(pixmap->devPrivate.ptr, 0, pixmap->devKind*height); #if HAS_PIXMAN_GLYPHS if (sna->render.glyph_cache) { + pixman_glyph_cache_t *cache = sna->render.glyph_cache; pixman_glyph_t stack_glyphs[N_STACK_GLYPHS]; pixman_glyph_t *pglyphs = stack_glyphs; - pixman_glyph_cache_t *cache; int count, n; - cache = sna->render.glyph_cache; - pixman_glyph_cache_freeze(cache); - count = 0; for (n = 0; n < nlist; ++n) count += list[n].len; @@ -1164,6 +1161,7 @@ glyphs_via_mask(struct sna *sna, goto err_pixmap; } + pixman_glyph_cache_freeze(cache); count = 0; do { n = list->len; @@ -2053,23 +2051,21 @@ glyphs_via_image(struct sna *sna, memset(pixmap->devPrivate.ptr, 0, pixmap->devKind*height); #if HAS_PIXMAN_GLYPHS if (sna->render.glyph_cache) { + pixman_glyph_cache_t *cache = sna->render.glyph_cache; pixman_glyph_t stack_glyphs[N_STACK_GLYPHS]; pixman_glyph_t *pglyphs = stack_glyphs; - pixman_glyph_cache_t *cache; int count, n; - cache = sna->render.glyph_cache; - pixman_glyph_cache_freeze(cache); - count = 0; for (n = 0; n < nlist; ++n) count += list[n].len; if (count > N_STACK_GLYPHS) { - pglyphs = malloc (count * sizeof(pixman_glyph_t)); + pglyphs = malloc(count * sizeof(pixman_glyph_t)); if (pglyphs == NULL) goto err_pixmap; } + pixman_glyph_cache_freeze(cache); count = 0; do { n = list->len;