From: Eric Leblond Date: Tue, 10 Jun 2025 09:42:12 +0000 (+0200) Subject: decode: light refactor on packet cleaning X-Git-Tag: suricata-8.0.0-rc1~13 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=1deca143317c712ef8ff6d6f14224acad939ba58;p=thirdparty%2Fsuricata.git decode: light refactor on packet cleaning --- diff --git a/src/decode.c b/src/decode.c index 6167d45225..693f0273aa 100644 --- a/src/decode.c +++ b/src/decode.c @@ -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,