From f165d9102665ac696f5ab97a2cd06d3bad10619d Mon Sep 17 00:00:00 2001 From: zhdguy Date: Mon, 27 Jul 2020 10:01:48 +0800 Subject: [PATCH] OpenGLES: fix CodeDex issue. Do not check null pointer of attrib_list. --- opengl/libs/EGL/eglApi.cpp | 51 +++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp index 213c971ad..4147af874 100644 --- a/opengl/libs/EGL/eglApi.cpp +++ b/opengl/libs/EGL/eglApi.cpp @@ -436,32 +436,37 @@ EGLBoolean eglChooseConfig( EGLDisplay dpy, const EGLint *attrib_list, } } - EGLint temp_attribs[temp_index + 1]; - memcpy(&temp_attribs[0], attrib_list, (temp_index + 1) * sizeof(EGLint)); - - if (temp_index > 0) { - for (int i = 0; i < temp_index; i += 2) { - switch (temp_attribs[i]) { - case EGL_RENDERABLE_TYPE: - //temp_attribs[i + 1] = EGL_OPENGL_ES2_BIT; - break; - case EGL_SURFACE_TYPE: - //temp_attribs[i + 1] = EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT; - break; - case EGL_STENCIL_SIZE: - temp_attribs[i + 1] = 8; - break; - case EGL_SAMPLES: - case EGL_SAMPLE_BUFFERS: - temp_attribs[i + 1] = 0; - break; - default: - break; + if (attrib_list) { + EGLint temp_attribs[temp_index + 1]; + memcpy(&temp_attribs[0], attrib_list, (temp_index + 1) * sizeof(EGLint)); + + if (temp_index > 0) { + for (int i = 0; i < temp_index; i += 2) { + switch (temp_attribs[i]) { + case EGL_RENDERABLE_TYPE: + //temp_attribs[i + 1] = EGL_OPENGL_ES2_BIT; + break; + case EGL_SURFACE_TYPE: + //temp_attribs[i + 1] = EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT; + break; + case EGL_STENCIL_SIZE: + temp_attribs[i + 1] = 8; + break; + case EGL_SAMPLES: + case EGL_SAMPLE_BUFFERS: + temp_attribs[i + 1] = 0; + break; + default: + break; + } } } + res = cnx->egl.eglChooseConfig( + dp->disp.dpy, temp_attribs, configs, config_size, num_config); + } else { + res = cnx->egl.eglChooseConfig( + dp->disp.dpy, attrib_list, configs, config_size, num_config); } - res = cnx->egl.eglChooseConfig( - dp->disp.dpy, temp_attribs, configs, config_size, num_config); } return res; } -- Gitee