From d326d32e24cbcda97c429d935fb869abf972a977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Tue, 7 Sep 2021 17:53:41 +0200 Subject: [PATCH] glx: Prevent crashes when an extension isn't found MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid a NULL-pointer dereference. Fixes: 2c8a85b712e ("glx: Stash a copy of the XExtCodes in the glx_display") Signed-off-by: Corentin Noël Reviewed-by: Adam Jackson Part-of: --- src/glx/glxext.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/glx/glxext.c b/src/glx/glxext.c index 91d021e710e..07bb42e22fe 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -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