[Mesa-dev] [PATCH] glx:dri_common.c: check psc->driScreen->createDrawable return value

Wang YanQing udknight at gmail.com
Mon Mar 19 20:49:42 PDT 2012


createDrawable may return NULL value, we should check it, or it will
make a segment failed.

Signed-off-by: Wang YanQing <udknight at gmail.com>
---
 src/glx/dri_common.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
index e7dba5a..6122d32 100644
--- a/src/glx/dri_common.c
+++ b/src/glx/dri_common.c
@@ -376,6 +376,12 @@ driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
 
    pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
                                           glxDrawable, gc->config);
+
+   if (pdraw == NULL) {
+     fprintf(stderr, "failed to create drawable\n");
+     return NULL;
+   }
+
    if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) {
       (*pdraw->destroyDrawable) (pdraw);
       return NULL;
-- 
1.7.9.2.315.g25a78



More information about the mesa-dev mailing list