mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
macOS: fix mem leaks
This commit is contained in:
@@ -110,6 +110,8 @@ endif()
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--tsaware -Wl,--build-id -Wl,--subsystem,console:6.1,--major-os-version,6,--minor-os-version,1")
|
||||
elseif(APPLE)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fobjc-arc")
|
||||
endif()
|
||||
|
||||
# Used for dlopen finding dylibs installed by homebrew
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "os.h"
|
||||
#include "common/io/io.h"
|
||||
#include "common/sysctl.h"
|
||||
#include "util/stringUtils.h"
|
||||
#include "util/mallocHelper.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -72,11 +74,11 @@ static bool detectOSCodeName(FFOSResult* os)
|
||||
|
||||
static void parseOSXSoftwareLicense(FFOSResult* os)
|
||||
{
|
||||
FILE* rtf = fopen("/System/Library/CoreServices/Setup Assistant.app/Contents/Resources/en.lproj/OSXSoftwareLicense.rtf", "r");
|
||||
FF_AUTO_CLOSE_FILE FILE* rtf = fopen("/System/Library/CoreServices/Setup Assistant.app/Contents/Resources/en.lproj/OSXSoftwareLicense.rtf", "r");
|
||||
if(rtf == NULL)
|
||||
return;
|
||||
|
||||
char* line = NULL;
|
||||
FF_AUTO_FREE char* line = NULL;
|
||||
size_t len = 0;
|
||||
const char* searchStr = "\\f0\\b SOFTWARE LICENSE AGREEMENT FOR macOS ";
|
||||
while(getline(&line, &len, rtf) != EOF)
|
||||
@@ -89,11 +91,6 @@ static void parseOSXSoftwareLicense(FFOSResult* os)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(line != NULL)
|
||||
free(line);
|
||||
|
||||
fclose(rtf);
|
||||
}
|
||||
|
||||
void ffDetectOSImpl(FFOSResult* os)
|
||||
|
||||
@@ -17,7 +17,7 @@ static NSDictionary* getWifiInfoByApple80211(NSString* ifName)
|
||||
|
||||
struct Apple80211* handle = NULL;
|
||||
if (Apple80211Open(&handle) < 0) return NULL;
|
||||
if (Apple80211BindToInterface(handle, (CFStringRef)ifName) < 0) return NULL;
|
||||
if (Apple80211BindToInterface(handle, (__bridge CFStringRef)ifName) < 0) return NULL;
|
||||
CFDictionaryRef result;
|
||||
if (Apple80211GetInfoCopy(handle, &result) < 0) return NULL;
|
||||
Apple80211Close(handle);
|
||||
|
||||
Reference in New Issue
Block a user