summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-12-17 15:39:43 -0800
committerMinh Nguyễn <mxn@1ec5.org>2016-12-23 03:36:55 -0800
commit2c62f0a15bed02bc6ca014fd113d5e62d9808624 (patch)
treebf1a5ce9204efbac9e6a4f3a0462561f92e338da
parent077cbb5e4b889a457e5bad5557ed4f7fb3d9ac72 (diff)
downloadqtlocation-mapboxgl-2c62f0a15bed02bc6ca014fd113d5e62d9808624.tar.gz
[ios, macos] Fixed null expression crash
Convert NSNull into an mbgl null value.
-rw-r--r--platform/darwin/src/NSExpression+MGLAdditions.mm5
-rw-r--r--platform/darwin/test/MGLExpressionTests.mm9
2 files changed, 12 insertions, 2 deletions
diff --git a/platform/darwin/src/NSExpression+MGLAdditions.mm b/platform/darwin/src/NSExpression+MGLAdditions.mm
index 392a6d7f5b..6af069487e 100644
--- a/platform/darwin/src/NSExpression+MGLAdditions.mm
+++ b/platform/darwin/src/NSExpression+MGLAdditions.mm
@@ -55,9 +55,10 @@
// We use long long here to avoid any truncation.
return { (int64_t)number.longLongValue };
}
+ } else if (value != [NSNull null]) {
+ [NSException raise:@"Value not handled"
+ format:@"Can’t convert %s:%@ to mbgl::Value", [value objCType], value];
}
- [NSException raise:@"Value not handled"
- format:@"Can’t convert %s:%@ to mbgl::Value", [value objCType], value];
return { };
}
diff --git a/platform/darwin/test/MGLExpressionTests.mm b/platform/darwin/test/MGLExpressionTests.mm
index 971f7d0e54..e78f87a99b 100644
--- a/platform/darwin/test/MGLExpressionTests.mm
+++ b/platform/darwin/test/MGLExpressionTests.mm
@@ -197,4 +197,13 @@
}
}
+#pragma mark - Null Tests
+
+- (void)testExpressionConversionNull
+{
+ NSComparisonPredicate *predicate = [self equalityComparisonPredicateWithRightConstantValue:[NSNull null]];
+ mbgl::Value convertedValue = predicate.rightExpression.mgl_filterValue;
+ XCTAssertTrue(convertedValue.is<mbgl::NullValue>());
+}
+
@end