File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -213,6 +213,9 @@ impl SafeWrite {
213213
214214impl io:: Write for SafeWrite {
215215 fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
216+ if self . buffer . is_none ( ) {
217+ return Err ( io:: ErrorKind :: WriteZero . into ( ) ) ;
218+ }
216219 // if there is too much data inside the buffer, return WoundBlock
217220 let buffer = self . buffer . as_mut ( ) . expect ( "buffer mut expected" ) ;
218221 if !matches ! ( self . status, WriteStatus :: Ok ) {
@@ -233,6 +236,9 @@ impl io::Write for SafeWrite {
233236 }
234237
235238 fn flush ( & mut self ) -> io:: Result < ( ) > {
239+ if self . buffer . is_none ( ) {
240+ return Err ( io:: ErrorKind :: WriteZero . into ( ) ) ;
241+ }
236242 let buffer = self . buffer . as_mut ( ) . expect ( "buffer mut expected" ) ;
237243 if !matches ! ( self . status, WriteStatus :: Ok ) {
238244 match std:: mem:: replace ( & mut self . status , WriteStatus :: Ok ) {
You can’t perform that action at this time.
0 commit comments