[Mesa-dev] [PATCH] dri_util: Assume error checking is done properly in glXMakeCurrent

Keith Whitwell keithw at vmware.com
Mon Apr 26 07:46:09 PDT 2010


On Mon, 2010-04-26 at 07:43 -0700, jakob at vmware.com wrote:
> From: Jakob Bornecrantz <jakob at vmware.com>
> 
> In short what the code did before:
> 
>     __DRIscreen *psp = NULL;
>     if (pcp)
>        psp = pcp->psb;
> 
>     assert(psp);
>     if (psp->stuff)
>        other_stuff();
> 
>     return psb->even_more(pcp);
> 
> Remove all that stupid checking which still segfaults/asserts later on and
> just do what we do in driUnbindContext.
> 
> Cheers Jakob.
> 
> ---
>  src/mesa/drivers/dri/common/dri_util.c |   31 +++++++++++++++++--------------
>  1 files changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
> index 11c189a..c84d32e 100644
> --- a/src/mesa/drivers/dri/common/dri_util.c
> +++ b/src/mesa/drivers/dri/common/dri_util.c
> @@ -153,19 +153,24 @@ static int driBindContext(__DRIcontext *pcp,
>  {
>      __DRIscreen *psp = NULL;
>  
> -    /* Bind the drawable to the context */
> +    /*
> +    ** Assume error checking is done properly in glXMakeCurrent before
> +    ** calling driUnbindContext.
> +    */
>  
> -    if (pcp) {
> -	psp = pcp->driScreenPriv;
> -	pcp->driDrawablePriv = pdp;
> -	pcp->driReadablePriv = prp;
> -	if (pdp) {
> -	    pdp->driContextPriv = pcp;
> -    	    dri_get_drawable(pdp);
> -	}
> -	if ( prp && pdp != prp ) {
> -    	    dri_get_drawable(prp);
> -	}
> +    if (pcp)
> +	return GL_FALSE;

Did you test this?  It looks like this will return false on valid inputs
and segfault otherwise...

Keith





More information about the mesa-dev mailing list