[Mesa-dev] [PATCH 2/2] egl: correct surface_type when add config

Liu Zhiquan zhiquan.liu at intel.com
Thu Jan 12 07:14:40 UTC 2017


When add config, dri_config is double or single. Should only add
EGL_WINDOW_BIT to surface_type for double dri_config, Should only add
EGL_PBUFFER_BIT EGL_PIXMAP_BIT to surface_type for single dri_config.
This avoid crash when operate on wrong surface_type which
dri_double_config or dri_single_config is null.

Signed-off-by: Liu Zhiquan <zhiquan.liu at intel.com>
Signed-off-by: Long, Zhifang <zhifang.long at intel.com>
---
 src/egl/drivers/dri2/egl_dri2.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index ac231d0..60b24ad 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -287,6 +287,11 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
       return NULL;
    }
 
+   if (surface_type & (double_buffer ? EGL_WINDOW_BIT : (EGL_PBUFFER_BIT | EGL_PIXMAP_BIT)))
+      surface_type &= ~(!double_buffer ? EGL_WINDOW_BIT : (EGL_PBUFFER_BIT | EGL_PIXMAP_BIT));
+   else
+      return NULL;
+
    config_id = base.ConfigID;
    base.ConfigID    = EGL_DONT_CARE;
    base.SurfaceType = EGL_DONT_CARE;
@@ -325,10 +330,6 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
       return NULL;
    }
 
-   if (double_buffer) {
-      surface_type &= ~EGL_PIXMAP_BIT;
-   }
-
    conf->base.SurfaceType |= surface_type;
 
    return conf;
-- 
1.9.1



More information about the mesa-dev mailing list