We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2b45a0d commit c4c533aCopy full SHA for c4c533a
src/libstd/sys/windows/os.rs
@@ -75,16 +75,15 @@ pub fn error_string(errnum: i32) -> String {
75
langId,
76
buf.as_mut_ptr(),
77
buf.len() as DWORD,
78
- ptr::null());
+ ptr::null()) as usize;
79
if res == 0 {
80
// Sometimes FormatMessageW can fail e.g. system doesn't like langId,
81
let fm_err = errno();
82
return format!("OS Error {} (FormatMessageW() returned error {})",
83
errnum, fm_err);
84
}
85
86
- let b = buf.iter().position(|&b| b == 0).unwrap_or(buf.len());
87
- match String::from_utf16(&buf[..b]) {
+ match String::from_utf16(&buf[..res]) {
88
Ok(mut msg) => {
89
// Trim trailing CRLF inserted by FormatMessageW
90
let len = msg.trim_right().len();
0 commit comments