Skip to content

Commit aadf233

Browse files
committed
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.
1 parent dd37077 commit aadf233

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lightning/src/util/ser.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ impl<'a, R: Read> BufRead for BufReader<'a, R> {
111111
self.is_consumed = count == 0;
112112
}
113113

114-
Ok(&self.buf[..])
114+
if self.is_consumed {
115+
Ok(&[])
116+
} else {
117+
Ok(&self.buf[..])
118+
}
115119
}
116120

117121
#[inline]

0 commit comments

Comments
 (0)