diff --git a/legacy/evas/src/lib/canvas/evas_object_image.c b/legacy/evas/src/lib/canvas/evas_object_image.c index c06fbbc762..937a0c4778 100644 --- a/legacy/evas/src/lib/canvas/evas_object_image.c +++ b/legacy/evas/src/lib/canvas/evas_object_image.c @@ -965,6 +965,10 @@ evas_object_image_data_get(const Evas_Object *obj, Eina_Bool for_writing) for_writing, &data, &o->load_error); + + /* if we fail to get engine_data, we have to return NULL */ + if (!o->engine_data) return NULL; + if (o->engine_data) { int stride = 0; diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c b/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c index c0b3f56af4..0a3bc82ee7 100644 --- a/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c +++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c @@ -524,73 +524,37 @@ _pool_tex_dynamic_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, i 0, attr); if (!pt->dyn.img) { + glBindTexture(GL_TEXTURE_2D, 0); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - return pt; + glDeleteTextures(1, &(pt->texture)); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + free(pt); + return NULL; } if (secsym_eglGetImageAttribSEC(egldisplay, pt->dyn.img, EGL_MAP_GL_TEXTURE_WIDTH_SEC, - &(pt->dyn.w)) != EGL_TRUE) - { - secsym_eglDestroyImage(egldisplay, pt->dyn.img); - pt->dyn.img = NULL; - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - return pt; - } + &(pt->dyn.w)) != EGL_TRUE) goto error; if (secsym_eglGetImageAttribSEC(egldisplay, pt->dyn.img, EGL_MAP_GL_TEXTURE_HEIGHT_SEC, - &(pt->dyn.h)) != EGL_TRUE) - { - secsym_eglDestroyImage(egldisplay, pt->dyn.img); - pt->dyn.img = NULL; - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - return pt; - } + &(pt->dyn.h)) != EGL_TRUE) goto error; if (secsym_eglGetImageAttribSEC(egldisplay, pt->dyn.img, EGL_MAP_GL_TEXTURE_STRIDE_IN_BYTES_SEC, - &(pt->dyn.stride)) != EGL_TRUE) - { - secsym_eglDestroyImage(egldisplay, pt->dyn.img); - pt->dyn.img = NULL; - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - return pt; - } + &(pt->dyn.stride)) != EGL_TRUE) goto error; if (secsym_eglGetImageAttribSEC(egldisplay, pt->dyn.img, EGL_MAP_GL_TEXTURE_FORMAT_SEC, - &(fmt)) != EGL_TRUE) - { - secsym_eglDestroyImage(egldisplay, pt->dyn.img); - pt->dyn.img = NULL; - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - return pt; - } - if (fmt != EGL_MAP_GL_TEXTURE_RGBA_SEC) - { - secsym_eglDestroyImage(egldisplay, pt->dyn.img); - pt->dyn.img = NULL; - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - return pt; - } + &(fmt)) != EGL_TRUE) goto error; + if (fmt != EGL_MAP_GL_TEXTURE_RGBA_SEC) goto error; + if (secsym_eglGetImageAttribSEC(egldisplay, pt->dyn.img, EGL_MAP_GL_TEXTURE_PIXEL_TYPE_SEC, - &(pixtype)) != EGL_TRUE) - { - secsym_eglDestroyImage(egldisplay, pt->dyn.img); - pt->dyn.img = NULL; - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - return pt; - } - if (pixtype != EGL_MAP_GL_TEXTURE_UNSIGNED_BYTE_SEC) - { - secsym_eglDestroyImage(egldisplay, pt->dyn.img); - pt->dyn.img = NULL; - GLERR(__FUNCTION__, __FILE__, __LINE__, ""); - return pt; - } + &(pixtype)) != EGL_TRUE) goto error; + + if (pixtype != EGL_MAP_GL_TEXTURE_UNSIGNED_BYTE_SEC) goto error; glBindTexture(GL_TEXTURE_2D, gc->pipe[0].shader.cur_tex); GLERR(__FUNCTION__, __FILE__, __LINE__, ""); @@ -602,6 +566,19 @@ _pool_tex_dynamic_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, i format = 0; #endif return pt; + +/* ERROR HANDLING */ +error: + secsym_eglDestroyImage(egldisplay, pt->dyn.img); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + pt->dyn.img = NULL; + + glBindTexture(GL_TEXTURE_2D, 0); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + glDeleteTextures(1, &(pt->texture)); + GLERR(__FUNCTION__, __FILE__, __LINE__, ""); + free(pt); + return NULL; } void diff --git a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c index edde055e26..d766aacc98 100644 --- a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c +++ b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c @@ -1797,6 +1797,16 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i eng_window_use(re->win); #endif + /* Engine can be fail to create texture after cache drop like eng_image_content_hint_set function, + so it is need to add code which check im->im's NULL value*/ + + if (!im->im) + { + *image_data = NULL; + if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; + return NULL; + } + error = evas_cache_image_load_data(&im->im->cache_entry); switch (im->cs.space) { @@ -1816,7 +1826,7 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i { *image_data = NULL; if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; - return im; + return NULL; } evas_gl_common_image_free(im); im = im_new;