mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-04 04:03:22 +03:00
file(READ_MACHO): Avoid crash on unknown archs in this undocumented command
`macho_arch_name_for_cpu_type` is implemented by the dynamic loader that ships with the OS, so it can only report architectures that were released at the time that OS was released. It can return `nullptr`. Fixes: #26680 Fixes: #28118 Issue: #28124
This commit is contained in:
1 parent
a907066b88
commit
6d52fa636f
1 file changed
+6
-3
+6
-3
@@ -375,9 +375,12 @@ cmMachO::StringList cmMachO::GetArchitectures() const
|
||||
char const* archName = "unknown";
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 130000
|
||||
if (__builtin_available(macOS 13.0, *)) {
|
||||
archName = (header.CpuType & CPU_TYPE_ARM)
|
||||
? macho_arch_name_for_cpu_type(header.CpuType, header.CpuSubType)
|
||||
: macho_arch_name_for_cpu_type(header.CpuType, CPU_SUBTYPE_MULTIPLE);
|
||||
if (char const* archNameForCpuType = (header.CpuType & CPU_TYPE_ARM)
|
||||
? macho_arch_name_for_cpu_type(header.CpuType, header.CpuSubType)
|
||||
: macho_arch_name_for_cpu_type(header.CpuType,
|
||||
CPU_SUBTYPE_MULTIPLE)) {
|
||||
archName = archNameForCpuType;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user