glx: Prevent crashes when an extension isn't found

Avoid a NULL-pointer dereference.

Fixes: 2c8a85b712 ("glx: Stash a copy of the XExtCodes in the glx_display")
Signed-off-by: Corentin Noël <corentin.noel@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12751>
This commit is contained in:
Corentin Noël 2021-09-07 17:53:41 +02:00 committed by Marge Bot
parent 20ec247cb8
commit d326d32e24

View file

@ -861,6 +861,7 @@ AllocAndFetchScreenConfigs(Display * dpy, struct glx_display * priv)
_X_HIDDEN struct glx_display *
__glXInitialize(Display * dpy)
{
XExtCodes *codes;
struct glx_display *dpyPriv, *d;
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
Bool glx_direct, glx_accel;
@ -883,8 +884,13 @@ __glXInitialize(Display * dpy)
if (!dpyPriv)
return NULL;
dpyPriv->codes = *XInitExtension(dpy, __glXExtensionName);
codes = XInitExtension(dpy, __glXExtensionName);
if (!codes) {
free(dpyPriv);
return NULL;
}
dpyPriv->codes = *codes;
dpyPriv->dpy = dpy;
/* This GLX implementation requires X_GLXQueryExtensionsString