summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2019-09-17 16:13:50 -0400
committerGitHub <noreply@github.com>2019-09-17 16:13:50 -0400
commit634c95c8d91a0833272557a76ec189780b20a284 (patch)
treed1c8c75af32e90359b939e63ad1994e62fc363e1 /platform
parent3dbc44404f2d8110d9c6cf82247e3df0df36f6b6 (diff)
downloadqtlocation-mapboxgl-634c95c8d91a0833272557a76ec189780b20a284.tar.gz
[ios, macos] Ensure potential variables that might be nil have a fallback. (#15645)
* [ios] Ensure potential variables that might be nil have a fallback. * [ios, macos] (potentially) free the returned arch info.
Diffstat (limited to 'platform')
-rw-r--r--platform/darwin/src/MGLSDKMetricsManager.m15
1 files changed, 12 insertions, 3 deletions
diff --git a/platform/darwin/src/MGLSDKMetricsManager.m b/platform/darwin/src/MGLSDKMetricsManager.m
index ed48eaf0c1..828fbcd505 100644
--- a/platform/darwin/src/MGLSDKMetricsManager.m
+++ b/platform/darwin/src/MGLSDKMetricsManager.m
@@ -42,12 +42,21 @@ NSString* MGLStringFromMetricType(MGLMetricType metricType) {
[UIScreen mainScreen].bounds.size.height];
NSLocale *currentLocale = [NSLocale currentLocale];
- NSString *country = [currentLocale objectForKey:NSLocaleCountryCode];
+
+ NSString *country = [currentLocale objectForKey:NSLocaleCountryCode] ?: @"unknown";
NSString *device = deviceName();
- const NXArchInfo localArchInfo = *NXGetLocalArchInfo();
- NSString *abi = [NSString stringWithUTF8String:localArchInfo.description];
+ NSString *abi = @"unknown";
+
+ {
+ const NXArchInfo *localArchInfo = NXGetLocalArchInfo();
+
+ if (localArchInfo) {
+ abi = @(localArchInfo->description);
+ NXFreeArchInfo(localArchInfo);
+ }
+ }
NSString *ram = [NSString stringWithFormat:@"%llu", [NSProcessInfo processInfo].physicalMemory];