YaGL: Fix glTexImageXXX NULL pointer offset bug 60/20160/1 submit/tizen/20140428.162945
authorStanislav Vorobiov <s.vorobiov@samsung.com>
Mon, 28 Apr 2014 15:36:33 +0000 (19:36 +0400)
committerStanislav Vorobiov <s.vorobiov@samsung.com>
Mon, 28 Apr 2014 15:41:11 +0000 (19:41 +0400)
If we set non-0 GL_UNPACK_SKIP_XXX and call glTexImageXXX
with NULL pointer then NULL will get offset and it'll result in
guest app crash. We should offset NULL data pointer only
if unpack PBO is bound, when no unpack PBO bound we
should just calculate the size and don't offset the pointer

Change-Id: Ie921016f0245f7042393cae98f04f80300bc85a1
Signed-off-by: Stanislav Vorobiov <s.vorobiov@samsung.com>
GLES_common/yagl_gles_calls.c
GLESv2/yagl_gles2_calls.c

index 0d56a44bf55e5c39fa0f832ebc1709a44661076f..85bf0cac20b744127ede18004bd7753256cba87e 100644 (file)
@@ -2242,8 +2242,13 @@ YAGL_API void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLs
         }
     }
 
-    pixels += yagl_pixel_format_get_info(pf, &ctx->unpack,
-                                         width, height, 1, &size);
+    if (pixels || using_pbo) {
+        pixels += yagl_pixel_format_get_info(pf, &ctx->unpack,
+                                             width, height, 1, &size);
+    } else {
+        yagl_pixel_format_get_info(pf, &ctx->unpack,
+                                   width, height, 1, &size);
+    }
 
     if (using_pbo) {
         yagl_host_glTexImage2DOffset(target,
index 8a5f5aa623fef6454f00368494d5d726ffac9313..8bc7e86e98b7ea4bf8cdaa68f385714d2015bca2 100644 (file)
@@ -2447,8 +2447,13 @@ YAGL_API void glTexImage3D(GLenum target, GLint level, GLint internalformat, GLs
         goto out;
     }
 
-    pixels += yagl_pixel_format_get_info(pf, &ctx->base.unpack,
-                                         width, height, depth, &size);
+    if (pixels || using_pbo) {
+        pixels += yagl_pixel_format_get_info(pf, &ctx->base.unpack,
+                                             width, height, depth, &size);
+    } else {
+        yagl_pixel_format_get_info(pf, &ctx->base.unpack,
+                                   width, height, depth, &size);
+    }
 
     if (using_pbo) {
         yagl_host_glTexImage3DOffset(target,