From bad900516133a81afb0a6d3982fa3de5871e6ba7 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 26 Apr 2022 20:02:19 +0200 Subject: [PATCH] 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. --- src/detect-engine-address-ipv6.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/detect-engine-address-ipv6.c b/src/detect-engine-address-ipv6.c index 00fcaddd53..3179628c6d 100644 --- a/src/detect-engine-address-ipv6.c +++ b/src/detect-engine-address-ipv6.c @@ -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]), SCNtohl(b->ip2.addr_data32[2]), SCNtohl(b->ip2.addr_data32[3]) }; - DetectAddress *tmp = NULL; - /* default to NULL */ *c = NULL; @@ -378,12 +376,6 @@ int DetectAddressCutIPv6(DetectEngineCtx *de_ctx, DetectAddress *a, 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] * part a: a_ip1 <-> b_ip1 - 1 * part b: b_ip1 <-> a_ip2 @@ -522,14 +514,9 @@ int DetectAddressCutIPv6(DetectEngineCtx *de_ctx, DetectAddress *a, } } - if (tmp != NULL) - DetectAddressFree(tmp); - return 0; error: - if (tmp != NULL) - DetectAddressFree(tmp); return -1; }