From 20bbe325fec0e5cd43f04dcbe62776a413224723 Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Tue, 12 May 2020 21:26:42 +0200 Subject: [PATCH] Cedar/Proto.c: fix wrong NULL check in ProtoHandleDatagrams(), found by Coverity *** CID 358434: Null pointer dereferences (REVERSE_INULL) /src/Cedar/Proto.c: 451 in ProtoHandleDatagrams() 445 void ProtoHandleDatagrams(UDPLISTENER *listener, LIST *datagrams) 446 { 447 UINT i; 448 HASH_LIST *sessions; 449 PROTO *proto = listener->Param; 450 >>> CID 358434: Null pointer dereferences (REVERSE_INULL) >>> Null-checking "listener" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 451 if (proto == NULL || listener == NULL || datagrams == NULL) 452 { 453 return; 454 } 455 456 sessions = proto->Sessions; --- src/Cedar/Proto.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Cedar/Proto.c b/src/Cedar/Proto.c index d4299da0..2c59f371 100644 --- a/src/Cedar/Proto.c +++ b/src/Cedar/Proto.c @@ -445,14 +445,15 @@ bool ProtoHandleConnection(PROTO *proto, SOCK *sock) void ProtoHandleDatagrams(UDPLISTENER *listener, LIST *datagrams) { UINT i; + PROTO *proto; HASH_LIST *sessions; - PROTO *proto = listener->Param; - if (proto == NULL || listener == NULL || datagrams == NULL) + if (listener == NULL || datagrams == NULL) { return; } + proto = listener->Param; sessions = proto->Sessions; for (i = 0; i < LIST_NUM(datagrams); ++i)