sna/glyph: Release the pixman glyph cache along the error paths
authorChris Wilson <chris@chris-wilson.co.uk>
Mon, 10 Mar 2014 16:38:54 +0000 (16:38 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 10 Mar 2014 22:12:22 +0000 (22:12 +0000)
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 <chris@chris-wilson.co.uk>
src/sna/sna_glyphs.c

index c72c5e5..eca0df0 100644 (file)
@@ -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;