diff options
author | Shinwoo Kim <cinoo.kim@samsung.com> | 2021-01-14 13:47:06 +0900 |
---|---|---|
committer | Shinwoo Kim <cinoo.kim@samsung.com> | 2021-01-14 13:47:26 +0900 |
commit | 34b0d0e973274c1a3df2386a30ad2a31bfcfe0d7 (patch) | |
tree | 42662b9eff9661e05779d7337e493f8e3a30ddfa | |
parent | f6d0bc1b2980098859f6181bf823c6b627ae6a5b (diff) |
gl: remove invalid read and write
Summary:
There could be 2 evas_gl_image referencing 1 evas_gl_texture.
evas_object_image_orient_set could make this case.
In this case, when one evas_gl_image is removed(free), the evas_gl_texture
is not removed because its reference count.
After this point, if the other evas_gl_image is removed without drawing
(see function evas_gl_common_image_draw, line "im->tex->im = im")
then evas_gl_texture is reading invalid adress when it is removed.
Reviewers: Hermet, jsuya, herb, devilhorns
Reviewed By: devilhorns
Subscribers: devilhorns, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D12229
-rw-r--r-- | src/modules/evas/engines/gl_common/evas_gl_common.h | 2 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_common/evas_gl_image.c | 10 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_common/evas_gl_texture.c | 7 |
3 files changed, 14 insertions, 5 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h b/src/modules/evas/engines/gl_common/evas_gl_common.h index c7b4d22150..2d9d825a75 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_common.h +++ b/src/modules/evas/engines/gl_common/evas_gl_common.h | |||
@@ -723,7 +723,7 @@ Evas_GL_Texture *evas_gl_common_texture_render_noscale_new(Evas_Engine_GL_Conte | |||
723 | Evas_GL_Texture *evas_gl_common_texture_dynamic_new(Evas_Engine_GL_Context *gc, Evas_GL_Image *im); | 723 | Evas_GL_Texture *evas_gl_common_texture_dynamic_new(Evas_Engine_GL_Context *gc, Evas_GL_Image *im); |
724 | void evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im); | 724 | void evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im); |
725 | void evas_gl_common_texture_upload(Evas_GL_Texture *tex, RGBA_Image *im, unsigned int bytes_count); | 725 | void evas_gl_common_texture_upload(Evas_GL_Texture *tex, RGBA_Image *im, unsigned int bytes_count); |
726 | void evas_gl_common_texture_free(Evas_GL_Texture *tex, Eina_Bool force); | 726 | Eina_Bool evas_gl_common_texture_free(Evas_GL_Texture *tex, Eina_Bool force); |
727 | Evas_GL_Texture *evas_gl_common_texture_alpha_new(Evas_Engine_GL_Context *gc, DATA8 *pixels, unsigned int w, unsigned int h, int fh); | 727 | Evas_GL_Texture *evas_gl_common_texture_alpha_new(Evas_Engine_GL_Context *gc, DATA8 *pixels, unsigned int w, unsigned int h, int fh); |
728 | void evas_gl_common_texture_alpha_update(Evas_GL_Texture *tex, DATA8 *pixels, unsigned int w, unsigned int h, int fh); | 728 | void evas_gl_common_texture_alpha_update(Evas_GL_Texture *tex, DATA8 *pixels, unsigned int w, unsigned int h, int fh); |
729 | Evas_GL_Texture *evas_gl_common_texture_yuv_new(Evas_Engine_GL_Context *gc, DATA8 **rows, unsigned int w, unsigned int h); | 729 | Evas_GL_Texture *evas_gl_common_texture_yuv_new(Evas_Engine_GL_Context *gc, DATA8 **rows, unsigned int w, unsigned int h); |
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 2d9383305a..13ca077cac 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_image.c +++ b/src/modules/evas/engines/gl_common/evas_gl_image.c | |||
@@ -720,7 +720,15 @@ evas_gl_common_image_free(Evas_GL_Image *im) | |||
720 | { | 720 | { |
721 | if (_evas_gl_image_cache_add(im)) return; | 721 | if (_evas_gl_image_cache_add(im)) return; |
722 | } | 722 | } |
723 | if (im->tex) evas_gl_common_texture_free(im->tex, EINA_TRUE); | 723 | if (im->tex) |
724 | { | ||
725 | if (!evas_gl_common_texture_free(im->tex, EINA_TRUE)) | ||
726 | { | ||
727 | /* if texture is not freed, we need to assign im to NULL | ||
728 | because after this point im will be freed */ | ||
729 | im->tex->im = NULL; | ||
730 | } | ||
731 | } | ||
724 | if (im->im) | 732 | if (im->im) |
725 | evas_cache_image_drop(&im->im->cache_entry); | 733 | evas_cache_image_drop(&im->im->cache_entry); |
726 | 734 | ||
diff --git a/src/modules/evas/engines/gl_common/evas_gl_texture.c b/src/modules/evas/engines/gl_common/evas_gl_texture.c index 47dd8305a8..049e4236cb 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_texture.c +++ b/src/modules/evas/engines/gl_common/evas_gl_texture.c | |||
@@ -1550,10 +1550,10 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im) | |||
1550 | im->cache_entry.flags.textured = 1; | 1550 | im->cache_entry.flags.textured = 1; |
1551 | } | 1551 | } |
1552 | 1552 | ||
1553 | void | 1553 | Eina_Bool |
1554 | evas_gl_common_texture_free(Evas_GL_Texture *tex, Eina_Bool force) | 1554 | evas_gl_common_texture_free(Evas_GL_Texture *tex, Eina_Bool force) |
1555 | { | 1555 | { |
1556 | if (!tex) return; | 1556 | if (!tex) return EINA_FALSE; |
1557 | if (force) | 1557 | if (force) |
1558 | { | 1558 | { |
1559 | evas_gl_preload_pop(tex); | 1559 | evas_gl_preload_pop(tex); |
@@ -1562,7 +1562,7 @@ evas_gl_common_texture_free(Evas_GL_Texture *tex, Eina_Bool force) | |||
1562 | evas_gl_preload_target_unregister(tex, eina_list_data_get(tex->targets)); | 1562 | evas_gl_preload_target_unregister(tex, eina_list_data_get(tex->targets)); |
1563 | } | 1563 | } |
1564 | tex->references--; | 1564 | tex->references--; |
1565 | if (tex->references != 0) return; | 1565 | if (tex->references != 0) return EINA_FALSE; |
1566 | if (tex->fglyph) | 1566 | if (tex->fglyph) |
1567 | { | 1567 | { |
1568 | tex->gc->font_glyph_textures_size -= tex->w * tex->h * 4; | 1568 | tex->gc->font_glyph_textures_size -= tex->w * tex->h * 4; |
@@ -1617,6 +1617,7 @@ evas_gl_common_texture_free(Evas_GL_Texture *tex, Eina_Bool force) | |||
1617 | } | 1617 | } |
1618 | 1618 | ||
1619 | evas_gl_common_texture_light_free(tex); | 1619 | evas_gl_common_texture_light_free(tex); |
1620 | return EINA_TRUE; | ||
1620 | } | 1621 | } |
1621 | 1622 | ||
1622 | Evas_GL_Texture * | 1623 | Evas_GL_Texture * |