[Mesa-dev] [PATCH 3/5] glx: add missing null check in SendMakeCurrentRequest

Ian Romanick idr at freedesktop.org
Mon Feb 17 12:42:59 PST 2014


NAK.  At this point, priv cannot be NULL.  All of the paths that lead
here have already called __glXSetupForCommand.  In that function, there
is either already a context, or it calls __glXInitialize to create the
dpy private structure.  If there is already a context, dpy must exist in
the table __glXInitialize uses, so it won't return NULL when called
again. If __glXSetupForCommand calls __glXInitialize, it will either
error out before getting to SendMakeCurrentRequest or the next call to
__glXInitialize will return the same pointer.

Not only that, but the point of the version check is to figure out which
protocol the server understands.  If libGL can't figure out which
protocol to send, picking something at random is not the answer.  It
should raise an error.

This is a Klocwork false-positive.

On 02/14/2014 05:23 AM, Juha-Pekka Heikkila wrote:
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> ---
>  src/glx/indirect_glx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/glx/indirect_glx.c b/src/glx/indirect_glx.c
> index 28b8cd0..306bf5b 100644
> --- a/src/glx/indirect_glx.c
> +++ b/src/glx/indirect_glx.c
> @@ -84,7 +84,7 @@ SendMakeCurrentRequest(Display * dpy, CARD8 opcode,
>         * not the SGI extension.
>         */
>  
> -      if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
> +      if (priv && ((priv->majorVersion > 1) || (priv->minorVersion >= 3))) {
>           xGLXMakeContextCurrentReq *req;
>  
>           GetReq(GLXMakeContextCurrent, req);
> 



More information about the mesa-dev mailing list