[Mesa-dev] [PATCH] egl: Added NULL check in eglCreateContext

Valentin Corfu corfuvalentin at gmail.com
Tue Dec 2 00:10:28 PST 2014


With this check we can avoid segmentation fault when invalid value used during eglCreateContext.

Cc: mesa-stable at lists.freedesktop.org
Cc: mesa-dev at lists.freedesktop.org
Signed-off-by: Valentin Corfu <valentinx.corfu at intel.com>
---
 src/egl/drivers/dri2/egl_dri2.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index d795a2f..819cb77 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -808,6 +808,11 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
 
    (void) drv;
 
+   if (conf == NULL) {
+      _eglError(EGL_BAD_CONFIG, "dri2_create_context");
+      return NULL;
+   }
+
    dri2_ctx = malloc(sizeof *dri2_ctx);
    if (!dri2_ctx) {
       _eglError(EGL_BAD_ALLOC, "eglCreateContext");
-- 
1.9.1



More information about the mesa-dev mailing list