Skip to content

Commit

Permalink
test(fix): use from_utf8_unchecked on Windows for getPassword
Browse files Browse the repository at this point in the history
Signed-off-by: Trae Yelovich <[email protected]>
  • Loading branch information
traeok committed Jul 28, 2023
1 parent cb2cd23 commit 612de17
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions packages/secrets/src/keyring/src/os/win.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,10 @@ pub fn get_password(service: &String, account: &String) -> Result<Option<String>
unsafe {
let bytes =
std::slice::from_raw_parts((*cred).CredentialBlob, (*cred).CredentialBlobSize as usize);
let string = String::from_utf8_unchecked(bytes.to_vec());

CredFree(cred as *const c_void);
return match String::from_utf8(bytes.to_vec()) {
Ok(str) => Ok(Some(str)),
Err(err) => Err(KeyringError::Utf8(
format!("Failed to convert credential to UTF-8: {}", err).to_owned(),
)),
};
Ok(Some(string))
}
}

Expand Down

0 comments on commit 612de17

Please sign in to comment.