From bf44764e9991265ed2f29dd1c018fecbeb2ed0c3 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 4 Oct 2025 16:20:37 -0700 Subject: [PATCH] Xext/vidmode: avoid null dereference if VidModeCreateMode() allocation fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported in #1817: xwayland-24.1.6/redhat-linux-build/../Xext/vidmode.c:96:5: warning[-Wanalyzer-null-argument]: use of NULL ‘VidModeCreateMode()’ where non-null expected Signed-off-by: Alan Coopersmith Part-of: (cherry picked from commit 5e62aaaf57b18136969699fd073e123edfb1aa70) --- Xext/vidmode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Xext/vidmode.c b/Xext/vidmode.c index 0bee0549c..04010eb11 100644 --- a/Xext/vidmode.c +++ b/Xext/vidmode.c @@ -808,6 +808,8 @@ ProcVidModeModModeLine(ClientPtr client) return BadValue; modetmp = VidModeCreateMode(); + if (modetmp == NULL) + return BadAlloc; VidModeCopyMode(mode, modetmp); VidModeSetModeValue(modetmp, VIDMODE_H_DISPLAY, stuff->hdisplay); @@ -951,6 +953,8 @@ ProcVidModeValidateModeLine(ClientPtr client) return BadValue; modetmp = VidModeCreateMode(); + if (modetmp == NULL) + return BadAlloc; VidModeCopyMode(mode, modetmp); VidModeSetModeValue(modetmp, VIDMODE_H_DISPLAY, stuff->hdisplay);