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>
(cherry picked from commit d326d32e24)
This commit is contained in:
Corentin Noël 2021-09-07 17:53:41 +02:00 committed by Dylan Baker
parent d3f8c5ff90
commit d3701f91bb
2 changed files with 8 additions and 2 deletions

View file

@ -85,7 +85,7 @@
"description": "glx: Prevent crashes when an extension isn't found",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "2c8a85b712e03c0033f200ed9fe3dc780ab7834d"
},

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