detect: fix scan-build warnings

detect-engine-address.c:1140:17: warning: Use of memory after it is freed [unix.Malloc]
            r = DetectAddressCmp(ag, ag2);
                ^~~~~~~~~~~~~~~~~~~~~~~~~
detect-engine-address.c:1169:17: warning: Use of memory after it is freed [unix.Malloc]
            r = DetectAddressCmp(ag, ag2);
                ^~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.

detect-engine-port.c:1161:9: warning: Use of memory after it is freed [unix.Malloc]
        DetectPortPrint(ag2);
        ^~~~~~~~~~~~~~~~~~~~
1 warning generated.

Bug: #3150.
Bug: #3151.
pull/8753/head
Victor Julien 2 years ago
parent c8694634af
commit 000064de7d

@ -1140,14 +1140,12 @@ int DetectAddressMergeNot(DetectAddressHead *gh, DetectAddressHead *ghn)
r = DetectAddressCmp(ag, ag2);
/* XXX more ??? */
if (r == ADDRESS_EQ || r == ADDRESS_EB) {
if (ag2->prev == NULL)
gh->ipv4_head = ag2->next;
else
if (ag2->prev != NULL)
ag2->prev->next = ag2->next;
if (ag2->next != NULL)
ag2->next->prev = ag2->prev;
if (gh->ipv4_head == ag2)
gh->ipv4_head = ag2->next;
/* store the next ptr and remove the group */
DetectAddress *next_ag2 = ag2->next;
DetectAddressFree(ag2);
@ -1168,14 +1166,12 @@ int DetectAddressMergeNot(DetectAddressHead *gh, DetectAddressHead *ghn)
for (ag2 = gh->ipv6_head; ag2 != NULL; ) {
r = DetectAddressCmp(ag, ag2);
if (r == ADDRESS_EQ || r == ADDRESS_EB) { /* XXX more ??? */
if (ag2->prev == NULL)
gh->ipv6_head = ag2->next;
else
if (ag2->prev != NULL)
ag2->prev->next = ag2->next;
if (ag2->next != NULL)
ag2->next->prev = ag2->prev;
if (gh->ipv6_head == ag2)
gh->ipv6_head = ag2->next;
/* store the next ptr and remove the group */
DetectAddress *next_ag2 = ag2->next;
DetectAddressFree(ag2);

@ -1137,15 +1137,12 @@ static int DetectPortParseMergeNotPorts(const DetectEngineCtx *de_ctx,
r = DetectPortCmp(ag, ag2);
if (r == PORT_EQ || r == PORT_EB) { /* XXX more ??? */
if (ag2->prev == NULL) {
*head = ag2->next;
} else {
if (ag2->prev != NULL)
ag2->prev->next = ag2->next;
}
if (ag2->next != NULL) {
if (ag2->next != NULL)
ag2->next->prev = ag2->prev;
}
if (*head == ag2)
*head = ag2->next;
/** store the next ptr and remove the group */
DetectPort *next_ag2 = ag2->next;
DetectPortFree(de_ctx,ag2);

Loading…
Cancel
Save