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

Michel Dänzer michel at daenzer.net
Tue Mar 20 00:49:25 PDT 2012


On Die, 2012-03-20 at 11:49 +0800, Wang YanQing wrote: 
> 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;
> +   }
> +

Please use one of the *MessageF() functions instead of fprintf directly.


-- 
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer


More information about the mesa-dev mailing list