From b430740a38971a03c7698d3e9e7e0c8eb5f9993d Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Fri, 7 Aug 2026 03:17:42 +0000 Subject: [PATCH 30/38] os (Apple): use non-ARC-only plist loading and NSAutoreleasePool guard Ported from https://github.com/macos-powerpc/powerpc-ports/blob/main/sysutils/fastfetch/files/0012-Misc-fixes-for-legacy-systems.patch --- src/detection/os/os_apple.m | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/detection/os/os_apple.m b/src/detection/os/os_apple.m index 570a72323..34cb74e90 100644 --- a/src/detection/os/os_apple.m +++ b/src/detection/os/os_apple.m @@ -6,31 +6,38 @@ #include #include -#import +#include + +#include + +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 +#define POOLSTART NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; +#define POOLEND [pool release]; +#else +#define POOLSTART +#define POOLEND +#endif static bool parseSystemVersion(FFOSResult* os) { - NSError* error; - NSString* fileName = @"file:///System/Library/CoreServices/SystemVersion.plist"; - NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:fileName] - error:&error]; - if(error) - return false; + POOLSTART + NSDictionary* dict = [NSDictionary dictionaryWithContentsOfFile: + @"/System/Library/CoreServices/SystemVersion.plist"]; NSString* value; - if((value = dict[@"ProductName"])) - ffStrbufInitS(&os->name, value.UTF8String); - if((value = dict[@"ProductUserVisibleVersion"])) - ffStrbufInitS(&os->version, value.UTF8String); - if((value = dict[@"ProductBuildVersion"])) - ffStrbufInitS(&os->buildID, value.UTF8String); + if ((value = [dict objectForKey:@"ProductName"])) + ffStrbufInitS(&os->name, [value UTF8String]); + if ((value = [dict objectForKey:@"ProductUserVisibleVersion"])) + ffStrbufInitS(&os->version, [value UTF8String]); + if ((value = [dict objectForKey:@"ProductBuildVersion"])) + ffStrbufInitS(&os->buildID, [value UTF8String]); if (ffStrbufStartsWithS(&os->version, "16.")) { // macOS 26 Tahoe. #1809 os->version.chars[0] = '2'; } - + POOLEND return true; } -- 2.43.0