diff --git a/src/session.rs b/src/session.rs index f17c0b7..640ac34 100644 --- a/src/session.rs +++ b/src/session.rs @@ -173,10 +173,16 @@ impl Session { } let size = size as usize; if size > buf.len() { + unsafe { + wintun.WintunReleaseReceivePacket(self.inner.0, ptr); + } use std::io::{Error, ErrorKind::InvalidInput}; return Err(Error::new(InvalidInput, "destination buffer too small")); } unsafe { ptr::copy_nonoverlapping(ptr, buf.as_mut_ptr(), size) }; + unsafe { + wintun.WintunReleaseReceivePacket(self.inner.0, ptr); + } Ok(size) }