diff --git a/src/tz_macos.rs b/src/tz_macos.rs index 165c539..b7dab99 100644 --- a/src/tz_macos.rs +++ b/src/tz_macos.rs @@ -11,9 +11,12 @@ unsafe fn get_timezone() -> Option { // The longest name in the IANA time zone database is 25 ASCII characters long. const MAX_LEN: usize = 32; - // Get system time zone, and its name. + // Get system time zone, and borrow its name. let tz = Dropping::new(CFTimeZoneCopySystem())?; - let name = Dropping::new(CFTimeZoneGetName(tz.0))?; + let name = match CFTimeZoneGetName(tz.0) { + name if !name.is_null() => name, + _ => return None, + }; // Copy the name into the buffer. let mut buf = [0; MAX_LEN];