From 13b8ac4a6a7a1d3dab54fefcf366ffb8366d3ef1 Mon Sep 17 00:00:00 2001 From: baishen Date: Sat, 3 Aug 2024 09:57:15 +0800 Subject: [PATCH] fix `TempFdArrayIterator` next panic --- src/collector.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/collector.rs b/src/collector.rs index c05fb18b..03fb9e05 100644 --- a/src/collector.rs +++ b/src/collector.rs @@ -221,6 +221,9 @@ impl<'a, T> Iterator for TempFdArrayIterator<'a, T> { Some(&self.buffer[self.index - 1]) } else { let length = self.file_vec.len() / std::mem::size_of::(); + if length == 0 { + return None; + } let ts = unsafe { std::slice::from_raw_parts(self.file_vec.as_ptr() as *const T, length) }; if self.index - self.buffer.len() < ts.len() {