[issue Fix the System::new() panicking on some PCs with Windows 10 (where system performance counter has empty content)
@@ -275,6 +275,10 @@ pub fn get_translation(s: &String, map: &HashMap<String, u32>) -> Option<String>
*index,
::std::ptr::null_mut(),
&mut size as *mut usize as *mut _);
+ if size == 0 {
+ return Some(String::new());
+ }
+ else {
let mut v = Vec::with_capacity(size);
v.set_len(size);
let _res = PdhLookupPerfNameByIndexW(::std::ptr::null(),
@@ -284,6 +288,7 @@ pub fn get_translation(s: &String, map: &HashMap<String, u32>) -> Option<String>
return Some(String::from_utf16(&v[..size - 1]).expect("invalid utf16"));
}
}
+ }
None
}
