From cef285311fda1cadbdcadeeb3259a6ae032dd652 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 10 Jun 2021 16:36:46 +0200 Subject: [PATCH] Remove unneeded NULL checks It's perfectly safe to delete NULL pointers, so simplify things by removing these checks. --- common/rfb/CSecurityStack.cxx | 6 ++---- common/rfb/CSecurityVeNCrypt.cxx | 3 +-- common/rfb/SSecurityStack.cxx | 6 ++---- common/rfb/SSecurityVeNCrypt.cxx | 6 +----- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/common/rfb/CSecurityStack.cxx b/common/rfb/CSecurityStack.cxx index 55f3133e..2541d81e 100644 --- a/common/rfb/CSecurityStack.cxx +++ b/common/rfb/CSecurityStack.cxx @@ -32,10 +32,8 @@ CSecurityStack::CSecurityStack(CConnection* cc, int Type, const char* Name, CSecurityStack::~CSecurityStack() { - if (state0) - delete state0; - if (state1) - delete state1; + delete state0; + delete state1; } bool CSecurityStack::processMsg() diff --git a/common/rfb/CSecurityVeNCrypt.cxx b/common/rfb/CSecurityVeNCrypt.cxx index 98dad494..a6b270e1 100644 --- a/common/rfb/CSecurityVeNCrypt.cxx +++ b/common/rfb/CSecurityVeNCrypt.cxx @@ -55,8 +55,7 @@ CSecurityVeNCrypt::CSecurityVeNCrypt(CConnection* cc, SecurityClient* sec) CSecurityVeNCrypt::~CSecurityVeNCrypt() { - if (availableTypes) - delete[] availableTypes; + delete[] availableTypes; } bool CSecurityVeNCrypt::processMsg() diff --git a/common/rfb/SSecurityStack.cxx b/common/rfb/SSecurityStack.cxx index 74509e71..81395113 100644 --- a/common/rfb/SSecurityStack.cxx +++ b/common/rfb/SSecurityStack.cxx @@ -28,10 +28,8 @@ SSecurityStack::SSecurityStack(SConnection* sc, int Type, SSecurityStack::~SSecurityStack() { - if (state0) - delete state0; - if (state1) - delete state1; + delete state0; + delete state1; } bool SSecurityStack::processMsg() diff --git a/common/rfb/SSecurityVeNCrypt.cxx b/common/rfb/SSecurityVeNCrypt.cxx index 135742c0..70d50d20 100644 --- a/common/rfb/SSecurityVeNCrypt.cxx +++ b/common/rfb/SSecurityVeNCrypt.cxx @@ -57,11 +57,7 @@ SSecurityVeNCrypt::SSecurityVeNCrypt(SConnection* sc, SecurityServer *sec) SSecurityVeNCrypt::~SSecurityVeNCrypt() { delete ssecurity; - - if (subTypes) { - delete [] subTypes; - subTypes = NULL; - } + delete [] subTypes; } bool SSecurityVeNCrypt::processMsg() -- 2.39.5