From: Victor Julien Date: Mon, 6 Aug 2018 10:08:20 +0000 (+0200) Subject: rust/dhcp: free events and destate at tx end X-Git-Tag: suricata-4.1.0-rc2~160 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F3446%2Fhead;p=thirdparty%2Fsuricata.git rust/dhcp: free events and destate at tx end --- 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);