From 0493eba694bae5730268174589a7c46e48a2ffdd Mon Sep 17 00:00:00 2001 From: Alexis Engelke Date: Fri, 3 Jul 2026 17:15:45 +0200 Subject: [PATCH] Fix reading of records without extra data perf.data files can have events like PERF_RECORD_FINISHED_INIT, where there is no data at all after the header. Handle this case and avoid returning an EOF error. --- src/parse.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/parse.rs b/src/parse.rs index 13c8e56..a76975a 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -389,7 +389,11 @@ where /// Consume the rest of the buffer and return it as a slice. pub fn parse_rest(&mut self) -> ParseResult> { - let mut bytes = self.data.chunk()?.to_cow(); + let mut bytes = match self.data.chunk() { + Ok(chunk) => chunk.to_cow(), + Err(e) if e.kind() == ErrorKind::Eof => return Ok(Cow::from(&[])), + Err(e) => return Err(e), + }; self.data.advance(bytes.len()); loop {