Skip to content

Commit

Permalink
Hotfix: send_ex improper use of iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubensei committed Jan 7, 2023
1 parent b8cfd2a commit df70e96
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion windivert/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "windivert"
version = "0.5.3"
version = "0.5.4"
description = "Wrapper library around windivert-sys"
authors = ["Ruben Serrano Izquierdo <rserranoizq@gmail.com>"]
repository = "https://github.com/Rubensei/windivert-rust.git"
Expand Down
5 changes: 2 additions & 3 deletions windivert/src/divert/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,15 @@ impl<L: layer::WinDivertLayerTrait> WinDivert<L> {
Ok(injected_length)
}

fn internal_send_ex<'data, 'packets, P>(&self, mut packets: P) -> Result<u32, WinDivertError>
fn internal_send_ex<'data, 'packets, P>(&self, packets: P) -> Result<u32, WinDivertError>
where
P: ExactSizeIterator<Item = &'packets WinDivertPacket<'data, L>>,
'data: 'packets,
L: 'packets,
{
let packet_count = packets.len();
let mut injected_length = 0;
let capacity = packets.by_ref().map(|p| p.data.len()).sum();
let mut packet_buffer: Vec<u8> = Vec::with_capacity(capacity);
let mut packet_buffer: Vec<u8> = Vec::new();
let mut address_buffer: Vec<WINDIVERT_ADDRESS> = Vec::with_capacity(packet_count);
packets.for_each(|packet: &'packets WinDivertPacket<'data, L>| {
packet_buffer.extend(&packet.data[..]);
Expand Down

0 comments on commit df70e96

Please sign in to comment.