From d3b28a5506d7dc1a7474be804483ebd01509ec93 Mon Sep 17 00:00:00 2001 From: Daniel Brotsky Date: Sun, 14 Jul 2024 00:06:23 -0700 Subject: [PATCH] Don't extend from an empty slice. Fixes kornelski/rust-security-framework#206. --- security-framework/src/passwords.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/security-framework/src/passwords.rs b/security-framework/src/passwords.rs index 75afe9bc..92cd9e5f 100644 --- a/security-framework/src/passwords.rs +++ b/security-framework/src/passwords.rs @@ -160,7 +160,9 @@ fn get_password_and_release(data: CFTypeRef) -> Result> { if type_id == CFData::type_id() { let val = unsafe { CFData::wrap_under_create_rule(data as CFDataRef) }; let mut vec = Vec::new(); - vec.extend_from_slice(val.bytes()); + if val.len() > 0 { + vec.extend_from_slice(val.bytes()); + } return Ok(vec); } // unexpected: we got a reference to some other type.