On Wednesday, 2018-02-21 09:26:34 -0500, Chuck Atkins wrote:
> This fixes a segfault exposed by a29d63ecf7 which occurs when swr is
> used on an unsupported architecture.
> 
> Signed-off-by: Chuck Atkins <[email protected]>
> Cc: [email protected]
> Cc: George Kyriazis <[email protected]>
> Cc: Bruce Cherniak <[email protected]>
> ---
>  src/gallium/state_trackers/glx/xlib/xm_api.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c 
> b/src/gallium/state_trackers/glx/xlib/xm_api.c
> index 934c0aba11..3aec57e85d 100644
> --- a/src/gallium/state_trackers/glx/xlib/xm_api.c
> +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
> @@ -182,9 +182,12 @@ xmesa_close_display(Display *display)
>      * }
>      */
>  
> -   if (xmdpy->smapi->destroy)
> -      xmdpy->smapi->destroy(xmdpy->smapi);
> -   free(xmdpy->smapi);
> +   if (xmdpy->smapi)
> +   {
> +      if (xmdpy->smapi->destroy)
> +         xmdpy->smapi->destroy(xmdpy->smapi);
> +      free(xmdpy->smapi);
> +   }

I don't know this code so I don't know if the patch is right, but just
pointing out this hunk could be written as a simple one-line change:

-   if (xmdpy->smapi->destroy)
+   if (xmdpy->smapi && xmdpy->smapi->destroy)

>  
>     XFree((char *) info);
>  }
> @@ -767,7 +770,7 @@ XMesaVisual XMesaCreateVisual( Display *display,
>     XMesaVisual v;
>     GLint red_bits, green_bits, blue_bits, alpha_bits;
>  
> -   if (!xmdpy)
> +   if (!xmdpy || !xmdpy->screen)
>        return NULL;
>  
>     /* For debugging only */
> -- 
> 2.14.3
> 
> _______________________________________________
> mesa-dev mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to