diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c b/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c index 0df660a946..d2586ac6b4 100644 --- a/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c +++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c @@ -105,6 +105,14 @@ evas_gl_common_image_load(Evas_Engine_GL_Context *gc, const char *file, const ch im_im = evas_common_load_image_from_file(file, key, lo, error); if (!im_im) return NULL; + + if ((im_im->cache_entry.w > gc->shared->info.max_texture_size) || + (im_im->cache_entry.h > gc->shared->info.max_texture_size)) + { + evas_cache_image_drop(&(im_im->cache_entry)); + *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; + return NULL; + } // FIXME: keep unreffed shared images around EINA_LIST_FOREACH(gc->shared->images, l, im) @@ -113,7 +121,7 @@ evas_gl_common_image_load(Evas_Engine_GL_Context *gc, const char *file, const ch { // why did i put this here? i think to free the rgba pixel data once a texture // exists. -// evas_cache_image_drop(&im_im->cache_entry); +// evas_cache_image_drop(&(im_im->cache_entry)); gc->shared->images = eina_list_remove_list(gc->shared->images, l); gc->shared->images = eina_list_prepend(gc->shared->images, im); evas_gl_common_image_ref(im); @@ -125,6 +133,7 @@ evas_gl_common_image_load(Evas_Engine_GL_Context *gc, const char *file, const ch im = calloc(1, sizeof(Evas_GL_Image)); if (!im) { + evas_cache_image_drop(&(im_im->cache_entry)); *error = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; return NULL; } @@ -147,6 +156,10 @@ evas_gl_common_image_new_from_data(Evas_Engine_GL_Context *gc, unsigned int w, u Evas_GL_Image *im; Eina_List *l; + if ((w > gc->shared->info.max_texture_size) || + (h > gc->shared->info.max_texture_size)) + return NULL; + if (data) { EINA_LIST_FOREACH(gc->shared->images, l, im) @@ -200,6 +213,10 @@ evas_gl_common_image_new_from_copied_data(Evas_Engine_GL_Context *gc, unsigned i { Evas_GL_Image *im; + if ((w > gc->shared->info.max_texture_size) || + (h > gc->shared->info.max_texture_size)) + return NULL; + im = calloc(1, sizeof(Evas_GL_Image)); if (!im) return NULL; im->references = 1; @@ -241,6 +258,10 @@ evas_gl_common_image_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned in { Evas_GL_Image *im; + if ((w > gc->shared->info.max_texture_size) || + (h > gc->shared->info.max_texture_size)) + return NULL; + im = calloc(1, sizeof(Evas_GL_Image)); if (!im) return NULL; im->references = 1; @@ -475,6 +496,10 @@ evas_gl_common_image_surface_new(Evas_Engine_GL_Context *gc, unsigned int w, uns { Evas_GL_Image *im; + if ((w > gc->shared->info.max_texture_size) || + (h > gc->shared->info.max_texture_size)) + return NULL; + im = calloc(1, sizeof(Evas_GL_Image)); if (!im) return NULL; im->references = 1;