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.
pull/7321/head
Victor Julien 4 years ago
parent bad9005161
commit f8a0f3d9b9

@ -1290,14 +1290,10 @@ int DetectAddressTestConfVars(void)
goto error; goto error;
} }
if (gh != NULL) { DetectAddressHeadFree(gh);
DetectAddressHeadFree(gh); gh = NULL;
gh = NULL; DetectAddressHeadFree(ghn);
} ghn = NULL;
if (ghn != NULL) {
DetectAddressHeadFree(ghn);
ghn = NULL;
}
} }
return 0; return 0;

Loading…
Cancel
Save