diff --git a/src/ios/CDVDevice.m b/src/ios/CDVDevice.m index 7315489..a0dd172 100644 --- a/src/ios/CDVDevice.m +++ b/src/ios/CDVDevice.m @@ -33,11 +33,22 @@ - (NSString*)modelVersion #if TARGET_IPHONE_SIMULATOR NSString* platform = NSProcessInfo.processInfo.environment[@"SIMULATOR_MODEL_IDENTIFIER"]; #else - size_t size; + size_t size = 0; + + if(sysctlbyname("hw.machine", NULL, &size, NULL, 0) != 0) { + return nil; + } - sysctlbyname("hw.machine", NULL, &size, NULL, 0); char* machine = malloc(size); - sysctlbyname("hw.machine", machine, &size, NULL, 0); + if(!machine) { + return nil; + } + + if(sysctlbyname("hw.machine", machine, &size, NULL, 0) != 0) { + free(machine); + return nil; + } + NSString* platform = [NSString stringWithUTF8String:machine]; free(machine); #endif