Skip to content

Commit 952152e

Browse files
committed
Global (macOS): always check NULL after IORegistryEntryCreateCFProperty
1 parent 6862747 commit 952152e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/detection/cpu/cpu_apple.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static const char* detectFrequency(FFCPUResult* cpu)
4444
return "\"pmgr\" should conform to \"AppleARMIODevice\"";
4545

4646
FF_CFTYPE_AUTO_RELEASE CFDataRef freqProperty = (CFDataRef) IORegistryEntryCreateCFProperty(entryDevice, CFSTR("voltage-states5-sram"), kCFAllocatorDefault, kNilOptions);
47-
if (CFGetTypeID(freqProperty) != CFDataGetTypeID())
47+
if (!freqProperty || CFGetTypeID(freqProperty) != CFDataGetTypeID())
4848
return "\"voltage-states5-sram\" in \"pmgr\" is not found";
4949

5050
// voltage-states5-sram stores supported <frequency / voltage> pairs of pcores from the lowest to the highest

src/detection/physicaldisk/physicaldisk_apple.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static inline void wrapIoDestroyPlugInInterface(IOCFPlugInInterface*** pluginInf
1818
if (*pluginInf)
1919
IODestroyPlugInInterface(*pluginInf);
2020
}
21-
#endif
21+
#endif
2222

2323
static const char* detectSsdTemp(io_service_t entryPhysical, double* temp)
2424
{
@@ -82,10 +82,12 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
8282
device->temperature = FF_PHYSICALDISK_TEMP_UNSET;
8383

8484
FF_CFTYPE_AUTO_RELEASE CFBooleanRef removable = IORegistryEntryCreateCFProperty(entryPartition, CFSTR(kIOMediaRemovableKey), kCFAllocatorDefault, kNilOptions);
85-
device->type |= CFBooleanGetValue(removable) ? FF_PHYSICALDISK_TYPE_REMOVABLE : FF_PHYSICALDISK_TYPE_FIXED;
85+
if (removable)
86+
device->type |= CFBooleanGetValue(removable) ? FF_PHYSICALDISK_TYPE_REMOVABLE : FF_PHYSICALDISK_TYPE_FIXED;
8687

8788
FF_CFTYPE_AUTO_RELEASE CFBooleanRef writable = IORegistryEntryCreateCFProperty(entryPartition, CFSTR(kIOMediaWritableKey), kCFAllocatorDefault, kNilOptions);
88-
device->type |= CFBooleanGetValue(writable) ? FF_PHYSICALDISK_TYPE_READWRITE : FF_PHYSICALDISK_TYPE_READONLY;
89+
if (writable)
90+
device->type |= CFBooleanGetValue(writable) ? FF_PHYSICALDISK_TYPE_READWRITE : FF_PHYSICALDISK_TYPE_READONLY;
8991

9092
FF_CFTYPE_AUTO_RELEASE CFStringRef bsdName = IORegistryEntryCreateCFProperty(entryPartition, CFSTR(kIOBSDNameKey), kCFAllocatorDefault, kNilOptions);
9193
if (bsdName)
@@ -125,7 +127,7 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
125127
}
126128
}
127129

128-
#ifdef MAC_OS_X_VERSION_10_15
130+
#ifdef MAC_OS_X_VERSION_10_15
129131
if (options->temp)
130132
{
131133
FF_CFTYPE_AUTO_RELEASE CFBooleanRef nvmeSMARTCapable = IORegistryEntryCreateCFProperty(entryPhysical, CFSTR(kIOPropertyNVMeSMARTCapableKey), kCFAllocatorDefault, kNilOptions);

0 commit comments

Comments
 (0)