[Mesa-dev] [PATCH 2/3] driX_glx.c: Draw and read must be either all non-zero or all zero

Xiong Zhang xiong.y.zhang at intel.com
Wed Mar 25 01:05:47 PDT 2015


Signed-off-by: Xiong Zhang <xiong.y.zhang at intel.com>
---
 src/glx/dri2_glx.c  | 5 +++++
 src/glx/dri3_glx.c  | 5 +++++
 src/glx/dri_glx.c   | 5 +++++
 src/glx/drisw_glx.c | 5 +++++
 4 files changed, 20 insertions(+)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 462d560..f980f82 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -142,6 +142,11 @@ dri2_bind_context(struct glx_context *context, struct glx_context *old,
    struct glx_display *dpyPriv = psc->base.display;
    struct dri2_display *pdp;
 
+   if ((draw != None && read == None) || (draw == None && read != None)) {
+      driReleaseDrawables(&pcp->base);
+      return GLXBadDrawable;
+   }
+
    pdraw = (struct dri2_drawable *) driFetchDrawable(context, draw);
    pread = (struct dri2_drawable *) driFetchDrawable(context, read);
 
diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index 058f7e7..4f94167 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -135,6 +135,11 @@ dri3_bind_context(struct glx_context *context, struct glx_context *old,
    struct dri3_drawable *pdraw, *pread;
    __DRIdrawable *dri_draw = NULL, *dri_read = NULL;
 
+   if ((draw != None && read == None) || (draw == None && read != None)) {
+      driReleaseDrawables(&pcp->base);
+      return GLXBadDrawable;
+   }
+
    pdraw = (struct dri3_drawable *) driFetchDrawable(context, draw);
    pread = (struct dri3_drawable *) driFetchDrawable(context, read);
 
diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c
index d087751..5c6c737 100644
--- a/src/glx/dri_glx.c
+++ b/src/glx/dri_glx.c
@@ -544,6 +544,11 @@ dri_bind_context(struct glx_context *context, struct glx_context *old,
    struct dri_screen *psc = (struct dri_screen *) pcp->base.psc;
    struct dri_drawable *pdraw, *pread;
 
+   if ((draw != None && read == None) || (draw == None && read != None)) {
+      driReleaseDrawables(&pcp->base);
+      return GLXBadDrawable;
+   }
+
    pdraw = (struct dri_drawable *) driFetchDrawable(context, draw);
    pread = (struct dri_drawable *) driFetchDrawable(context, read);
 
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index 749ceb0..aa74840 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -242,6 +242,11 @@ drisw_bind_context(struct glx_context *context, struct glx_context *old,
    struct drisw_screen *psc = (struct drisw_screen *) pcp->base.psc;
    struct drisw_drawable *pdraw, *pread;
 
+   if ((draw != None && read == None) || (draw == None && read != None)) {
+      driReleaseDrawables(&pcp->base);
+      return GLXBadDrawable;
+   }
+
    pdraw = (struct drisw_drawable *) driFetchDrawable(context, draw);
    pread = (struct drisw_drawable *) driFetchDrawable(context, read);
 
-- 
2.1.4



More information about the mesa-dev mailing list