Skip to content

Commit

Permalink
iOs: errors handling added to modelVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
RSATom committed Jul 26, 2022
1 parent 0cce7b4 commit b3a0d03
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/ios/CDVDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b3a0d03

Please sign in to comment.