]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
decode: light refactor on packet cleaning
authorEric Leblond <el@stamus-networks.com>
Tue, 10 Jun 2025 09:42:12 +0000 (11:42 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 11 Jun 2025 18:49:19 +0000 (20:49 +0200)
src/decode.c

index 6167d45225482d36923d6b02e64ea0581d644600..693f0273aa60936bd579765bfea2b238a91dee0f 100644 (file)
@@ -147,32 +147,32 @@ PacketAlert *PacketAlertCreate(void)
 
 void PacketAlertRecycle(PacketAlert *pa_array)
 {
-    if (pa_array != NULL) {
-        for (int i = 0; i < packet_alert_max; i++) {
-            struct PacketContextData *current_json = pa_array[i].json_info;
-            while (current_json) {
-                struct PacketContextData *next_json = current_json->next;
-                SCFree(current_json);
-                current_json = next_json;
-            }
-            pa_array[i].json_info = NULL;
+    if (pa_array == NULL)
+        return;
+    for (int i = 0; i < packet_alert_max; i++) {
+        struct PacketContextData *current_json = pa_array[i].json_info;
+        while (current_json) {
+            struct PacketContextData *next_json = current_json->next;
+            SCFree(current_json);
+            current_json = next_json;
         }
+        pa_array[i].json_info = NULL;
     }
 }
 
-void PacketAlertFree(PacketAlert *pa)
+void PacketAlertFree(PacketAlert *pa_array)
 {
-    if (pa != NULL) {
-        for (int i = 0; i < packet_alert_max; i++) {
-            struct PacketContextData *allocated_json = pa[i].json_info;
-            while (allocated_json) {
-                struct PacketContextData *next_json = allocated_json->next;
-                SCFree(allocated_json);
-                allocated_json = next_json;
-            }
+    if (pa_array == NULL)
+        return;
+    for (int i = 0; i < packet_alert_max; i++) {
+        struct PacketContextData *allocated_json = pa_array[i].json_info;
+        while (allocated_json) {
+            struct PacketContextData *next_json = allocated_json->next;
+            SCFree(allocated_json);
+            allocated_json = next_json;
         }
-        SCFree(pa);
     }
+    SCFree(pa_array);
 }
 
 static int DecodeTunnel(ThreadVars *, DecodeThreadVars *, Packet *, const uint8_t *, uint32_t,