detect/ipv6: remove useless code

Remove useless allocation and free.

Found by cppcheck as a potential issue:

src/detect-engine-address-ipv6.c:385:12: warning: Either the condition 'tmp!=NULL' is redundant or there is possible null pointer dereference: tmp. [nullPointerRedundantCheck]
    memset(tmp,0,sizeof(DetectAddress));
           ^
src/detect-engine-address-ipv6.c:525:13: note: Assuming that condition 'tmp!=NULL' is not redundant
    if (tmp != NULL)
            ^
src/detect-engine-address-ipv6.c:385:12: note: Null pointer dereference
    memset(tmp,0,sizeof(DetectAddress));
           ^

But code turned out not to do anything, so removed.

Bug: #5291.
pull/7321/head
Victor Julien 3 years ago
parent ea2d0ecf08
commit bad9005161

@ -368,8 +368,6 @@ int DetectAddressCutIPv6(DetectEngineCtx *de_ctx, DetectAddress *a,
uint32_t b_ip2[4] = { SCNtohl(b->ip2.addr_data32[0]), SCNtohl(b->ip2.addr_data32[1]), uint32_t b_ip2[4] = { SCNtohl(b->ip2.addr_data32[0]), SCNtohl(b->ip2.addr_data32[1]),
SCNtohl(b->ip2.addr_data32[2]), SCNtohl(b->ip2.addr_data32[3]) }; SCNtohl(b->ip2.addr_data32[2]), SCNtohl(b->ip2.addr_data32[3]) };
DetectAddress *tmp = NULL;
/* default to NULL */ /* default to NULL */
*c = NULL; *c = NULL;
@ -378,12 +376,6 @@ int DetectAddressCutIPv6(DetectEngineCtx *de_ctx, DetectAddress *a,
goto error; goto error;
} }
/* get a place to temporary put sigs lists */
tmp = DetectAddressInit();
if (tmp == NULL)
goto error;
memset(tmp,0,sizeof(DetectAddress));
/* we have 3 parts: [aaa[abab]bbb] /* we have 3 parts: [aaa[abab]bbb]
* part a: a_ip1 <-> b_ip1 - 1 * part a: a_ip1 <-> b_ip1 - 1
* part b: b_ip1 <-> a_ip2 * part b: b_ip1 <-> a_ip2
@ -522,14 +514,9 @@ int DetectAddressCutIPv6(DetectEngineCtx *de_ctx, DetectAddress *a,
} }
} }
if (tmp != NULL)
DetectAddressFree(tmp);
return 0; return 0;
error: error:
if (tmp != NULL)
DetectAddressFree(tmp);
return -1; return -1;
} }

Loading…
Cancel
Save