[PATCH] gl: don't access ctx after release

Yuanhan Liu <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
_cairo_gl_surface_map_to_image still access ctx->has_mesa_pack_invert after
release, which does't make sense.

Signed-off-by: Yuanhan Liu <[email protected]>
---
 src/cairo-gl-surface.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index b8710e5..86e5401 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -1017,6 +1017,7 @@ _cairo_gl_surface_map_to_image (void      *abstract_surface,
     GLenum format, type;
     pixman_format_code_t pixman_format;
     unsigned int cpp;
+    cairo_bool_t has_mesa_pack_invert;
     cairo_bool_t invert;
     cairo_status_t status;
     int y;
@@ -1092,8 +1093,9 @@ _cairo_gl_surface_map_to_image (void      *abstract_surface,
     _cairo_gl_composite_flush (ctx);
     _cairo_gl_context_set_destination (ctx, surface, FALSE);
 
+    has_mesa_pack_invert = ctx->has_mesa_pack_invert;
     invert = ! _cairo_gl_surface_is_texture (surface) &&
-	    ctx->has_mesa_pack_invert;
+	    has_mesa_pack_invert;
 
     glPixelStorei (GL_PACK_ALIGNMENT, 4);
     if (ctx->gl_flavor == CAIRO_GL_FLAVOR_DESKTOP)
@@ -1118,7 +1120,7 @@ _cairo_gl_surface_map_to_image (void      *abstract_surface,
     }
 
     /* We must invert the image manualy if we lack GL_MESA_pack_invert */
-    if (! ctx->has_mesa_pack_invert && ! _cairo_gl_surface_is_texture (surface)) {
+    if (! has_mesa_pack_invert && ! _cairo_gl_surface_is_texture (surface)) {
 	uint8_t stack[1024], *row = stack;
 	uint8_t *top = image->data;
 	uint8_t *bot = image->data + (image->height-1)*image->stride;
-- 
1.7.7.6

--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.