From aadf233d6c2974672e061d2ae755ac1f238812c9 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 16 Aug 2024 18:46:24 +0000 Subject: [PATCH] Fix bug in `BufReader::fill_buf` when reaching EOF When we reach EOF we may return a full buffer when we should return an empty one. --- lightning/src/util/ser.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lightning/src/util/ser.rs b/lightning/src/util/ser.rs index 19281110d..fbe1933a0 100644 --- a/lightning/src/util/ser.rs +++ b/lightning/src/util/ser.rs @@ -111,7 +111,11 @@ impl<'a, R: Read> BufRead for BufReader<'a, R> { self.is_consumed = count == 0; } - Ok(&self.buf[..]) + if self.is_consumed { + Ok(&[]) + } else { + Ok(&self.buf[..]) + } } #[inline] -- 2.39.5