From 4e4eb10495cc0d24b02c4cc82d86f3977f3cc95f Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 21 Jul 2024 10:05:36 -0700 Subject: parse_reply_call_callback: avoid NULL dereference if reply is missing data Clears up 7 -Wanalyzer-null-dereference warnings from gcc 14.1 Signed-off-by: Alan Coopersmith Part-of: --- src/XRecord.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/XRecord.c b/src/XRecord.c index 11d23f6..32c17bb 100644 --- a/src/XRecord.c +++ b/src/XRecord.c @@ -745,6 +745,8 @@ parse_reply_call_callback( */ switch (rep->category) { case XRecordFromServer: + if (reply == NULL) + goto out; if (rep->elementHeader&XRecordFromServerTime) { if (current_index + 4 > rep->length << 2) return Error; @@ -770,6 +772,8 @@ parse_reply_call_callback( } break; case XRecordFromClient: + if (reply == NULL) + goto out; if (rep->elementHeader&XRecordFromClientTime) { if (current_index + 4 > rep->length << 2) goto out; @@ -804,6 +808,8 @@ parse_reply_call_callback( datum_bytes <<= 2; break; case XRecordClientStarted: + if (reply == NULL) + goto out; if (current_index + 8 > rep->length << 2) goto out; EXTRACT_CARD16(rep->clientSwapped, @@ -812,6 +818,8 @@ parse_reply_call_callback( break; case XRecordClientDied: if (rep->elementHeader&XRecordFromClientSequence) { + if (reply == NULL) + goto out; if (current_index + 4 > rep->length << 2) goto out; EXTRACT_CARD32(rep->clientSwapped, -- cgit v1.2.3