File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,12 @@ impl<W: AsyncWrite> AsyncBufWrite for BufWriter<W> {
193193 }
194194
195195 fn produce ( self : Pin < & mut Self > , amt : usize ) {
196- * self . project ( ) . buffered += amt;
196+ let this = self . project ( ) ;
197+ assert ! (
198+ * this. buffered + amt <= this. buf. len( ) ,
199+ "produce called with amt exceeding buffer capacity"
200+ ) ;
201+ * this. buffered += amt;
197202 }
198203}
199204
Original file line number Diff line number Diff line change @@ -193,7 +193,12 @@ impl<W: AsyncWrite> AsyncBufWrite for BufWriter<W> {
193193 }
194194
195195 fn produce ( self : Pin < & mut Self > , amt : usize ) {
196- * self . project ( ) . buffered += amt;
196+ let this = self . project ( ) ;
197+ assert ! (
198+ * this. buffered + amt <= this. buf. len( ) ,
199+ "produce called with amt exceeding buffer capacity"
200+ ) ;
201+ * this. buffered += amt;
197202 }
198203}
199204
You can’t perform that action at this time.
0 commit comments