Closed Delphinidae84 closed 6 days ago
I have a rather simple function which reads values by key_path and value_name.
key_path
value_name
pub fn read_reg_key(key_path: &str, value_name: &str) -> Result<String, DirError> { let hklm = RegKey::predef(HKEY_LOCAL_MACHINE); let sub_key = match hklm.open_subkey(key_path) { Ok(sk) => sk, Err(_err) => return Err(DirError::GeneralFail), }; match sub_key.get_value(value_name) { Ok(val) => Ok(val), Err(_err) => Err(DirError::GeneralFail), } }
The content and length of the output looks correct:
But as soon as I manipulate the string in any way (for example value.push('/')), garbage appears to be appended to the original string.
value.push('/')
I tried to limit the string's by its len which is correct in the beginning:
len
value = value.chars().take(value.len()).collect();
But this also seems to append garbage to the string itself. Any idea what might be causing this behaviour?
I have a rather simple function which reads values by
key_path
andvalue_name
.The content and length of the output looks correct:
But as soon as I manipulate the string in any way (for example
value.push('/')
), garbage appears to be appended to the original string.I tried to limit the string's by its
len
which is correct in the beginning:But this also seems to append garbage to the string itself. Any idea what might be causing this behaviour?