From 2274f23e6029348a5baeb6d785b0e01ac35a52da Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 6 May 2025 14:36:57 +0200 Subject: [PATCH] glx: NULL-protect validGlxFBConfigForWindow() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If this ever happens, we clearly have a bug, so print out proper warning, instead of silently crashing the Xserver. | ../glx/glxcmds.c: In function ‘validGlxFBConfigForWindow’: | ../glx/glxcmds.c:127:16: warning: dereference of NULL ‘pVisual’ [CWE-476] [-Wanalyzer-null-dereference] | 127 | if (pVisual->class != glxConvertToXVisualType(config->visualType) || | | ~~~~~~~^~~~~~~ Signed-off-by: Enrico Weigelt, metux IT consult --- glx/glxcmds.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index f8c3a965c..54d6d7924 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -36,6 +36,7 @@ #include #include "dix/dix_priv.h" +#include "os/bug_priv.h" #include "glxserver.h" #include @@ -122,6 +123,8 @@ validGlxFBConfigForWindow(ClientPtr client, __GLXconfig * config, } } + BUG_RETURN_VAL(!pVisual, FALSE); + /* FIXME: What exactly should we check here... */ if (pVisual->class != glxConvertToXVisualType(config->visualType) || !(config->drawableType & GLX_WINDOW_BIT)) {