evas: change alloca->malloc for avoid stack overflow 80/126880/2
authorsunghyun kim <scholb.kim@samsung.com>
Tue, 25 Apr 2017 05:31:17 +0000 (14:31 +0900)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Tue, 2 May 2017 08:38:33 +0000 (08:38 +0000)
when texture upload using memcpy case, sometimes crash happens in enlightenment.
it may be memory corruption problem when alloac is failed because of Stack overflow
so i replace alloca to malloc for avoid stack overflow

Change-Id: I20ad80df73d9e63d832acfdf4a281743841b6b46

src/modules/evas/engines/gl_common/evas_gl_texture.c

index a99505a..1fe2c06 100644 (file)
@@ -1154,7 +1154,12 @@ evas_gl_common_texture_upload(Evas_GL_Texture *tex, RGBA_Image *im, unsigned int
         dh = im->cache_entry.h + 2;
         sw = im->cache_entry.w;
         sh = im->cache_entry.h;
-        DATA32 * temp = alloca (dw * dh * bytes_count);
+        DATA32 * temp = malloc (dw * dh * bytes_count);
+        if(!temp)
+          {
+             ERR("memory allocation is failed..");
+             return;
+          }
         DATA8 *dp = (unsigned char *)temp;
         DATA8 *sp = (unsigned char *)im->image.data;
         int i;
@@ -1184,6 +1189,7 @@ evas_gl_common_texture_upload(Evas_GL_Texture *tex, RGBA_Image *im, unsigned int
         // xxxxx
         memcpy(dp, dp + (dw * bytes_count), dw * bytes_count);
         _tex_sub_2d(tex->gc, tex->x - 1, tex->y - 1, dw, dh, fmt, tex->pt->dataformat, temp);
+        free(temp);
      }
    else
      {