macOS: fix mem leaks

This commit is contained in:
李通洲
2024-01-03 09:41:02 +08:00
parent ab028964bf
commit ff0f91dc3c
3 changed files with 7 additions and 8 deletions
+4 -7
View File
@@ -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)
+1 -1
View File
@@ -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);