]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/nfs: fix memory leak
authorVictor Julien <victor@inliniac.net>
Tue, 13 Feb 2018 13:04:04 +0000 (14:04 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 13 Feb 2018 13:04:04 +0000 (14:04 +0100)
rust/src/nfs/nfs.rs

index 8c3038c4eca858aea2647eec026a7a03d4205c98..29655344e418e1ca728b7d9c19606b7e2d6ce8ee 100644 (file)
@@ -321,6 +321,14 @@ pub struct NFSState {
     pub de_state_count: u64,
 }
 
+/// Implement Drop for NFSState as transactions need to do some
+/// explicit cleanup.
+impl Drop for NFSState {
+    fn drop(&mut self) {
+        self.free();
+    }
+}
+
 impl NFSState {
     /// Allocation function for a new TLS parser instance
     pub fn new() -> NFSState {
@@ -347,6 +355,9 @@ impl NFSState {
         }
     }
     pub fn free(&mut self) {
+        while self.transactions.len() > 0 {
+            self.free_tx_at_index(0);
+        }
         self.files.free();
     }