From f15c5702f87bb10aa5d5aceff250dfa9d2e1b634 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 21 Apr 2025 14:30:36 -0700 Subject: [PATCH] mouse.c: handle -Wanalyzer-null-dereference in createProtoList MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Should never happen, but the compiler would need to understand the flow of our state machine to realize that, and this protects us if that ever changes. Clears warning from gcc 14.2.0: mouse.c: In function ‘createProtoList’: mouse.c:3226:30: warning: dereference of NULL ‘protoList’ [CWE-476] [-Wanalyzer-null-dereference] 3226 | for (i = 0; protoList[i] != PROT_UNKNOWN; i++) { | ~~~~~~~~~^~~ Signed-off-by: Alan Coopersmith Part-of: --- src/mouse.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mouse.c b/src/mouse.c index 438e8ba..b79e425 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -3215,6 +3215,11 @@ createProtoList(MouseDevPtr pMse, MouseProtocolID *protoList) AP_DBGC(("%2.2x ", (unsigned char) mPriv->data[i])); AP_DBGC(("\n")); + if (protoList == NULL) { + AP_DBG(("Skipping probe, protoList is NULL")); + return; + } + #if HAVE_THREADED_INPUT input_lock(); #else