Narrow an unsafe block

This commit is contained in:
Richard Feldman 2026-07-08 16:12:32 -04:00
parent 469e14eccd
commit 85afc7d9af
No known key found for this signature in database

View file

@ -800,13 +800,13 @@ impl Platform for WindowsPlatform {
match NonNull::new(credentials) {
Some(credentials) => {
let username = unsafe { credentials.as_ref().UserName.to_string() };
let password: Result<Vec<u8>> = unsafe {
let password: Result<Vec<u8>> = {
let size = credentials.as_ref().CredentialBlobSize as usize;
match NonNull::new(credentials.as_ref().CredentialBlob) {
Some(credential_blob) => {
Ok(std::slice::from_raw_parts(credential_blob.as_ptr(), size)
.to_vec())
Some(credential_blob) => Ok(unsafe {
std::slice::from_raw_parts(credential_blob.as_ptr(), size)
}
.to_vec()),
None if size == 0 => Ok(Vec::new()),
None => Err(anyhow!(
"Windows credential blob was null with nonzero size"