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

Yuanhan Liu yuanhan.liu at linux.intel.com
Tue Mar 20 19:55:58 PDT 2012


On Tue, Mar 20, 2012 at 05:24:06PM +0800, Wang YanQing wrote:
> On Tue, Mar 20, 2012 at 08:49:25AM +0100, Michel Dänzer wrote:
> 
> > Please use one of the *MessageF() functions instead of fprintf directly.
> 
> 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 0e06d51..31e4d4d 100644
> --- a/src/glx/dri_common.c
> +++ b/src/glx/dri_common.c
> @@ -403,6 +403,12 @@ driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
>  
>     pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
>                                            glxDrawable, gc->config);
> +
> +   if (pdraw == NULL) {
> +     ErrorMessageF("failed to create drawable\n");
> +     return NULL;
> +   }
> +   

Looks good to me, except the minor indent issue.
Otherwise, 

Reviewed-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>

>     if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) {
>        (*pdraw->destroyDrawable) (pdraw);
>        return NULL;
> -- 
> 1.7.9.2.315.g25a78
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list