From 8b1b8d5cf04f5e176cc4de6c04790e90eeac4ff2 Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Wed, 11 Nov 2015 14:29:55 +0900 Subject: [PATCH] Evas GL: Fix crash with dynamic hint set using tbm surface Summary: if device support sec_tbm_surface, but doesn't support the EGL_NATIVE_SURFACE_TIZEN then below api called cause crash! evas_object_image_content_hint_set(o, EVAS_IMAGE_CONTENT_HINT_DYNAMIC); evas_object_image_alpha_set(o, 0); 1. evas_object_image_content_hint_set(o, EVAS_IMAGE_CONTENT_HINT_DYNAMIC); [evas_gl_image.c] if (im->im) { if (evas_cache2_image_cached(&im->im->cache_entry)) evas_cache2_image_close(&im->im->cache_entry); else evas_cache_image_drop(&im->im->cache_entry); im->im = NULL; // im->im now NULL!!! } im->tex = evas_gl_common_texture_dynamic_new(im->gc, im); // im->tex also NULL!! im->text also NULL!! because If driver does not support the EGL_NATIVE_SURFACE_TIZEN then below code return NULL at _pool_tex_dynamic_new(); pt->dyn.img = secsym_eglCreateImage(egldisplay, EGL_NO_CONTEXT, EGL_NATIVE_SURFACE_TIZEN, pt->dyn.buffer, attr); 2. evas_object_image_alpha_set(o, 0); [gl_generic/evas_engine.c] static void * eng_image_alpha_set() { now im->im and im->tex are null so crash happend at eng_image_alpha_set() } bug fixed in case of the tbm surface create fails so device cannot support the dynamic hit set, Test Plan: experdite Reviewers: jpeg, cedric, spacegrapher Subscribers: dkdk, scholb.kim, wonsik Differential Revision: https://phab.enlightenment.org/D3318 --- src/modules/evas/engines/gl_common/evas_gl_image.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/evas/engines/gl_common/evas_gl_image.c b/src/modules/evas/engines/gl_common/evas_gl_image.c index 2d8d936e2a..6646a29f63 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_image.c +++ b/src/modules/evas/engines/gl_common/evas_gl_image.c @@ -622,6 +622,10 @@ evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint) } if (im->content_hint == EVAS_IMAGE_CONTENT_HINT_DYNAMIC) { + Evas_GL_Texture *tex; + tex = evas_gl_common_texture_dynamic_new(im->gc, im); + if (!tex) return; + if (im->cs.data) { if (!im->cs.no_free) free(im->cs.data); @@ -650,7 +654,7 @@ evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint) evas_gl_common_texture_free(im->tex, EINA_TRUE); im->tex = NULL; } - im->tex = evas_gl_common_texture_dynamic_new(im->gc, im); + im->tex = tex; im->tex_only = 1; } else