From a337908c789f5cd4cd9d3c3d3de7ea1ed5b96919 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Mon, 6 Aug 2018 12:08:20 +0200 Subject: [PATCH] rust/dhcp: free events and destate at tx end --- rust/src/dhcp/dhcp.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/rust/src/dhcp/dhcp.rs b/rust/src/dhcp/dhcp.rs index 835af50f7f..756d1d0d21 100644 --- a/rust/src/dhcp/dhcp.rs +++ b/rust/src/dhcp/dhcp.rs @@ -18,6 +18,7 @@ use applayer; use core; use core::{ALPROTO_UNKNOWN, AppProto, Flow}; +use core::{sc_detect_engine_state_free, sc_app_layer_decoder_events_free_events}; use dhcp::parser::*; use libc; use log::*; @@ -98,6 +99,25 @@ impl DHCPTransaction { events: std::ptr::null_mut(), } } + + pub fn free(&mut self) { + if self.events != std::ptr::null_mut() { + sc_app_layer_decoder_events_free_events(&mut self.events); + } + match self.de_state { + Some(state) => { + sc_detect_engine_state_free(state); + } + _ => {} + } + } + +} + +impl Drop for DHCPTransaction { + fn drop(&mut self) { + self.free(); + } } export_tx_get_detect_state!(rs_dhcp_tx_get_detect_state, DHCPTransaction); -- 2.47.2