coregl_fastpath_egl: Check type before retrieving object 48/82848/2
authorZhaowei Yuan <zhaowei.yuan@samsung.com>
Sun, 7 Aug 2016 17:54:28 +0000 (01:54 +0800)
committerGwan-gyeong Mun <kk.moon@samsung.com>
Tue, 9 Aug 2016 02:27:07 +0000 (19:27 -0700)
Object type of argument buffer maybe either
TEXTURE or RENDERBUFFER, check it

Signed-off-by: Zhaowei Yuan <zhaowei.yuan@samsung.com>
Change-Id: I5468ef8105d29a6c655b064f2b2406dc9b1655e6

src/modules/fastpath/coregl_fastpath_egl.c

index 2cce314..ed3bcbc 100644 (file)
@@ -1345,6 +1345,16 @@ fastpath_eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target,
        void *ret = NULL;
        EGLContext real_ctx = EGL_NO_CONTEXT;
        EGLClientBuffer real_obj;
+       GL_Object_Type type = 0;
+
+       if((EGLint)buffer & GL_OBJECT_TYPE_TEXTURE)
+               type = GL_OBJECT_TYPE_TEXTURE;
+       else if((EGLint)buffer & GL_OBJECT_TYPE_RENDERBUFFER)
+               type = GL_OBJECT_TYPE_RENDERBUFFER;
+       else {
+               COREGL_ERR("\E[40;31;1m fastpath_eglCreateImageKHR buffer type error \E[0m\n");
+               goto finish;
+       }
 
        _COREGL_FASTPATH_FUNC_BEGIN();
 
@@ -1373,8 +1383,7 @@ fastpath_eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target,
                                real_obj = NULL;
                        } else {
                                real_obj = (EGLClientBuffer)(uintptr_t)fastpath_ostate_get_object(&gctx->ostate,
-                                               GL_OBJECT_TYPE_TEXTURE,
-                                               (GLuint)(uintptr_t)buffer);
+                                               type, (GLuint)(uintptr_t)buffer);
                        }
                        break;
                default:
@@ -1449,6 +1458,7 @@ fastpath_eglGetProcAddress(const char *procname)
 #include "../../headers/sym_gl1.h"
 #include "../../headers/sym_gl2.h"
 #include "../../headers/sym_gl_common.h"
+
 #undef _COREGL_EXT_SYMBOL_FASTPATH_PASS
 #undef _COREGL_EXT_SYMBOL_FASTPATH_BLOCK