From: Matt Corallo Date: Fri, 16 Aug 2024 18:46:24 +0000 (+0000) Subject: Fix bug in `BufReader::fill_buf` when reaching EOF X-Git-Tag: v0.0.124-beta~5^2~8 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=aadf233d6c2974672e061d2ae755ac1f238812c9;p=rust-lightning 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. --- 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]