From: Victor Julien Date: Tue, 13 Feb 2018 13:04:04 +0000 (+0100) Subject: rust/nfs: fix memory leak X-Git-Tag: suricata-4.0.4~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=add7b188f46ca42058ac00af9065a5ec2f14b7d8;p=thirdparty%2Fsuricata.git rust/nfs: fix memory leak --- diff --git a/rust/src/nfs/nfs.rs b/rust/src/nfs/nfs.rs index 8c3038c4ec..29655344e4 100644 --- a/rust/src/nfs/nfs.rs +++ b/rust/src/nfs/nfs.rs @@ -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(); }