summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJosh Ferrell <josh@vector35.com>2025-01-08 14:52:33 -0500
committerJosh Ferrell <josh@vector35.com>2025-01-08 14:52:33 -0500
commitb34393c33a82050dcb5e65d5fc7d36960c18e167 (patch)
tree073fdf2742a5266d1c4253d0b821fedf43b87b5b /platform
parentcc763dc7a962e13442c1bcfa4d36ba59c94c4f88 (diff)
Prevent crash when Mach-O view doesn't exist
Diffstat (limited to 'platform')
-rw-r--r--platform/mac/platform_mac.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/platform/mac/platform_mac.cpp b/platform/mac/platform_mac.cpp
index 6c2adf7a..2eec7f53 100644
--- a/platform/mac/platform_mac.cpp
+++ b/platform/mac/platform_mac.cpp
@@ -283,13 +283,14 @@ extern "C"
BINARYNINJAPLUGIN bool CorePluginInit()
#endif
{
- auto viewType = BinaryViewType::GetByName("Mach-O");
+ Ref<BinaryViewType> viewType = BinaryViewType::GetByName("Mach-O");
Ref<Architecture> x86 = Architecture::GetByName("x86");
if (x86)
{
g_macX86 = new MacX86Platform(x86);
Platform::Register("mac", g_macX86);
- viewType->RegisterPlatformRecognizer(7, LittleEndian, MacX86Platform::Recognize);
+ if (viewType)
+ viewType->RegisterPlatformRecognizer(7, LittleEndian, MacX86Platform::Recognize);
}
Ref<Architecture> x64 = Architecture::GetByName("x86_64");
@@ -297,7 +298,8 @@ extern "C"
{
g_macX64 = new MacX64Platform(x64);
Platform::Register("mac", g_macX64);
- viewType->RegisterPlatformRecognizer(0x01000007, LittleEndian, MacX64Platform::Recognize);
+ if (viewType)
+ viewType->RegisterPlatformRecognizer(0x01000007, LittleEndian, MacX64Platform::Recognize);
}
Ref<Architecture> armv7 = Architecture::GetByName("armv7");
@@ -316,8 +318,11 @@ extern "C"
Platform::Register("ios", g_iosArmv7);
Platform::Register("mac", g_macThumb2);
Platform::Register("ios", g_iosThumb2);
- viewType->RegisterPlatformRecognizer(0xc, LittleEndian, MacArmv7Platform::Recognize);
- viewType->RegisterPlatformRecognizer(0xc, LittleEndian, IOSArmv7Platform::Recognize);
+ if (viewType)
+ {
+ viewType->RegisterPlatformRecognizer(0xc, LittleEndian, MacArmv7Platform::Recognize);
+ viewType->RegisterPlatformRecognizer(0xc, LittleEndian, IOSArmv7Platform::Recognize);
+ }
}
Ref<Architecture> arm64 = Architecture::GetByName("aarch64");
@@ -327,11 +332,14 @@ extern "C"
g_iosArm64 = new IOSArm64Platform(arm64);
Platform::Register("mac", g_macArm64);
Platform::Register("ios", g_iosArm64);
- viewType->RegisterPlatformRecognizer(0, LittleEndian, MacArm64Platform::Recognize);
- viewType->RegisterPlatformRecognizer(0x0100000c, LittleEndian, MacArm64Platform::Recognize);
- viewType->RegisterPlatformRecognizer(0x0200000c, LittleEndian, MacArm64Platform::Recognize);
- viewType->RegisterPlatformRecognizer(0, LittleEndian, IOSArm64Platform::Recognize);
- viewType->RegisterPlatformRecognizer(0x0100000c, LittleEndian, IOSArm64Platform::Recognize);
+ if (viewType)
+ {
+ viewType->RegisterPlatformRecognizer(0, LittleEndian, MacArm64Platform::Recognize);
+ viewType->RegisterPlatformRecognizer(0x0100000c, LittleEndian, MacArm64Platform::Recognize);
+ viewType->RegisterPlatformRecognizer(0x0200000c, LittleEndian, MacArm64Platform::Recognize);
+ viewType->RegisterPlatformRecognizer(0, LittleEndian, IOSArm64Platform::Recognize);
+ viewType->RegisterPlatformRecognizer(0x0100000c, LittleEndian, IOSArm64Platform::Recognize);
+ }
}
return true;