From 1e055b5ddc18b85c7965c996d3ef4ab9c1b612a4 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 6 May 2025 14:35:26 +0200 Subject: [PATCH] glx: protect createModeFromConfig() from allocation failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit | ../glx/glxdricommon.c: In function ‘createModeFromConfig’: | ../glx/glxdricommon.c:142:23: warning: dereference of possibly-NULL ‘config’ [CWE-690] [-Wanalyzer-possible-null-dereference] | 142 | config->driConfig = driConfig; Consumers can already handle returning NULL, so this seems the best compromise. It will look like we don't have any modes at all. Certainly not nice, but at least better than completely crashing the Xserver. Signed-off-by: Enrico Weigelt, metux IT consult --- glx/glxdricommon.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/glx/glxdricommon.c b/glx/glxdricommon.c index 0d83fa714..851d0e0fe 100644 --- a/glx/glxdricommon.c +++ b/glx/glxdricommon.c @@ -136,6 +136,8 @@ createModeFromConfig(const __DRIcoreExtension * core, config = calloc(1, sizeof *config); + if (!config) + return NULL; config->driConfig = driConfig;