From 2715d80e18bbc97508e25dbf05987ff9999acc0a Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Wed, 24 Feb 2021 00:26:44 +0500 Subject: [PATCH] fix potential null pointer dereference found by Coverity CID 355460 (#1 of 1): Dereference before null check (REVERSE_INULL)check_after_deref: Null-checking p suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 737 if (p == NULL) 738 { 739 return false; 740 } --- src/Cedar/Proto_PPP.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Cedar/Proto_PPP.c b/src/Cedar/Proto_PPP.c index ef27ed3a..6ad76a2e 100644 --- a/src/Cedar/Proto_PPP.c +++ b/src/Cedar/Proto_PPP.c @@ -721,6 +721,12 @@ bool PPPProcessRetransmissions(PPP_SESSION *p) // Send the PPP Echo Request bool PPPSendEchoRequest(PPP_SESSION *p) { + // Validate arguments + if (p == NULL) + { + return false; + } + UINT64 now = Tick64(); if (p->NextEchoSendTime == 0 || now >= p->NextEchoSendTime) { @@ -733,12 +739,6 @@ bool PPPSendEchoRequest(PPP_SESSION *p) AddInterrupt(p->Ipc->Interrupt, p->NextEchoSendTime); } - // Validate arguments - if (p == NULL) - { - return false; - } - pp = ZeroMalloc(sizeof(PPP_PACKET)); pp->Protocol = PPP_PROTOCOL_LCP; pp->IsControl = true;