From 9b6db6b3b5005de99448c102258d9ac21944b8e1 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Tue, 14 Apr 2015 20:55:50 +0900 Subject: [PATCH] Evas GL: Add some safety code Set some pointers to NULL to avoid invalid accesses after free. Move the similar condition for sfc after the make_current check. --- src/modules/evas/engines/gl_common/evas_gl_core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.c b/src/modules/evas/engines/gl_common/evas_gl_core.c index 3c79e692f3..bd597df729 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_core.c +++ b/src/modules/evas/engines/gl_common/evas_gl_core.c @@ -1938,9 +1938,6 @@ evgl_surface_destroy(void *eng_data, EVGL_Surface *sfc) if ((dbg = evgl_engine->api_debug_mode)) DBG("Destroying surface sfc %p (eng %p)", sfc, eng_data); - if (sfc->current_ctx && sfc->current_ctx->current_sfc == sfc) - sfc->current_ctx->current_sfc = NULL; - if ((rsc->current_ctx) && (rsc->current_ctx->current_sfc == sfc) ) { if (evgl_engine->api_debug_mode) @@ -1956,6 +1953,9 @@ evgl_surface_destroy(void *eng_data, EVGL_Surface *sfc) evgl_make_current(eng_data, NULL, NULL); } + if (sfc->current_ctx && sfc->current_ctx->current_sfc == sfc) + sfc->current_ctx->current_sfc = NULL; + if (!sfc->pbuffer.native_surface) { // Set the context current with resource context/surface @@ -2123,6 +2123,9 @@ evgl_context_destroy(void *eng_data, EVGL_Context *ctx) if (dbg) DBG("Destroying context (eng = %p, ctx = %p)", eng_data, ctx); + if (ctx->current_sfc && (ctx->current_sfc->current_ctx == ctx)) + ctx->current_sfc->current_ctx = NULL; + // Set the context current with resource context/surface if (!_internal_resource_make_current(eng_data, NULL)) {