We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fb92de7 commit 2daa1b7Copy full SHA for 2daa1b7
src/libstd/sys/windows/os.rs
@@ -84,9 +84,13 @@ pub fn error_string(errnum: i32) -> String {
84
}
85
86
let b = buf.iter().position(|&b| b == 0).unwrap_or(buf.len());
87
- let msg = String::from_utf16(&buf[..b]);
88
- match msg {
89
- Ok(msg) => msg,
+ match String::from_utf16(&buf[..b]) {
+ Ok(mut msg) => {
+ // Trim trailing CRLF inserted by FormatMessageW
90
+ let len = msg.trim_right().len();
91
+ msg.truncate(len);
92
+ msg
93
+ },
94
Err(..) => format!("OS Error {} (FormatMessageW() returned \
95
invalid UTF-16)", errnum),
96
0 commit comments