From: Victor Julien Date: Tue, 26 Apr 2022 18:04:28 +0000 (+0200) Subject: detect/address: remove useless checks X-Git-Tag: suricata-5.0.10~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8d2ee4aa6dc75981ddbbdb16bc7c02525023eab;p=thirdparty%2Fsuricata.git detect/address: remove useless checks Cppcheck flagged this: src/detect-engine-address.c:1035:48: warning: Either the condition 'ghn!=NULL' is redundant or there is possible null pointer dereference: gh. [nullPointerRedundantCheck] int r = DetectAddressIsCompleteIPSpaceIPv4(gh->ipv4_head); ^ src/detect-engine-address.c:1297:17: note: Assuming that condition 'ghn!=NULL' is not redundant if (ghn != NULL) { ^ src/detect-engine-address.c:1283:44: note: Calling function 'DetectAddressIsCompleteIPSpace', 1st argument 'ghn' value is 0 if (DetectAddressIsCompleteIPSpace(ghn)) { ^ src/detect-engine-address.c:1035:48: note: Null pointer dereference int r = DetectAddressIsCompleteIPSpaceIPv4(gh->ipv4_head); ^ Cleanup code could only be reached with non-NULL pointers, so simplify checks. Bug: #5291. (cherry picked from commit f8a0f3d9b9f4e1aa758a493e00d38e98a552a0d6) --- diff --git a/src/detect-engine-address.c b/src/detect-engine-address.c index 26c5c3d139..51c4b8243a 100644 --- a/src/detect-engine-address.c +++ b/src/detect-engine-address.c @@ -1250,14 +1250,10 @@ int DetectAddressTestConfVars(void) goto error; } - if (gh != NULL) { - DetectAddressHeadFree(gh); - gh = NULL; - } - if (ghn != NULL) { - DetectAddressHeadFree(ghn); - ghn = NULL; - } + DetectAddressHeadFree(gh); + gh = NULL; + DetectAddressHeadFree(ghn); + ghn = NULL; } return 0;