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