mirror of
https://github.com/lahfir/agent-desktop.git
synced 2026-08-04 21:20:48 +00:00
fix(macos): harden retained_handle null guard against release-only CFRetain(null) (#80)
Make the retained_handle null check unconditional so release builds no longer risk CFRetain(null); tests keep benign placeholder behavior, production returns ElementNotFound.
This commit is contained in:
parent
cadbdf9602
commit
a708fa0332
1 changed files with 3 additions and 1 deletions
|
|
@ -84,9 +84,11 @@ fn text_len(value: Option<&str>) -> usize {
|
|||
#[cfg(target_os = "macos")]
|
||||
fn retained_handle(candidate: AXElement) -> Result<NativeHandle, AdapterError> {
|
||||
use core_foundation::base::{CFRetain, CFTypeRef};
|
||||
#[cfg(test)]
|
||||
if candidate.0.is_null() {
|
||||
#[cfg(test)]
|
||||
return Ok(NativeHandle::null());
|
||||
#[cfg(not(test))]
|
||||
return Err(AdapterError::element_not_found("element"));
|
||||
}
|
||||
unsafe { CFRetain(candidate.0 as CFTypeRef) };
|
||||
Ok(unsafe { NativeHandle::from_ptr(candidate.0 as *const _) })
|
||||
|
|
|
|||
Loading…
Reference in a new issue