]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/dhcp: free events and destate at tx end 3446/head
authorVictor Julien <victor@inliniac.net>
Mon, 6 Aug 2018 10:08:20 +0000 (12:08 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 6 Aug 2018 10:13:12 +0000 (12:13 +0200)
rust/src/dhcp/dhcp.rs

index 835af50f7f2cc018cfeed0c3b6ec7cb7a8d19766..756d1d0d21f6bb0a21a9164c431bb2ec14b90460 100644 (file)
@@ -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);