Skip to content

Commit 6465ab4

Browse files
committed
Fixes from PR
Signed-off-by: Ayush Singh <[email protected]>
1 parent a9a5ef9 commit 6465ab4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

library/std/src/sys/uefi/stdio.rs

+5-5
Original file line numberDiff line numberDiff 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) }?;

0 commit comments

Comments
 (0)