File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -40,11 +40,10 @@ impl io::Read for Stdin {
4040 return Err ( io:: const_io_error!( io:: ErrorKind :: Interrupted , "Special Key Press" ) ) ;
4141 }
4242
43- // The option unwrap is safe since iterator will have 1 element.
44- let ch: char = char:: decode_utf16 ( [ inp] )
45- . next ( )
46- . unwrap ( )
47- . map_err ( |_| io:: const_io_error!( io:: ErrorKind :: InvalidInput , "Invalid Input" ) ) ?;
43+ let Some ( Ok ( ch) ) = char:: decode_utf16 ( [ inp] ) . next ( ) else {
44+ return Err ( const_io_error ! ( io:: ErrorKind :: InvalidInput , "Invalid Input" ) ) ;
45+ } ;
46+
4847 if ch. len_utf8 ( ) > buf. len ( ) {
4948 self . pending = Some ( ch) ;
5049 return Ok ( 0 ) ;
@@ -116,6 +115,7 @@ fn write(
116115 } ;
117116
118117 let mut utf16: Vec < u16 > = utf8. encode_utf16 ( ) . collect ( ) ;
118+ // NULL terminate the string
119119 utf16. push ( 0 ) ;
120120
121121 unsafe { simple_text_output ( protocol, & mut utf16) } ?;
You can’t perform that action at this time.
0 commit comments