]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/ipv6: remove useless code
authorVictor Julien <vjulien@oisf.net>
Tue, 26 Apr 2022 18:02:19 +0000 (20:02 +0200)
committerVictor Julien <vjulien@oisf.net>
Wed, 4 May 2022 16:54:23 +0000 (18:54 +0200)
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.
(cherry picked from commit bad900516133a81afb0a6d3982fa3de5871e6ba7)

src/detect-engine-address-ipv6.c

index 00fcaddd5359ccf054468c010d90cc1e5dd184cc..3179628c6d551b0e57d56cd8811b623ef8e60625 100644 (file)
@@ -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;
 }