Title: [185122] trunk/Source/_javascript_Core
- Revision
- 185122
- Author
- commit-qu...@webkit.org
- Date
- 2015-06-02 14:24:10 -0700 (Tue, 02 Jun 2015)
Log Message
_javascript_Core: JSExport protocol with an NSInteger property converts negative values to 18446744073709552000
https://bugs.webkit.org/show_bug.cgi?id=145563
Patch by Keith Miller <keith_mil...@apple.com> on 2015-06-02
Reviewed by Darin Adler.
The Objective-C bindings were improperly converting negative
long long/NSIntegers to 18446744073709552000 because they
were converted to unsigned numbers.
* API/ObjcRuntimeExtras.h:
(parseObjCType):
* API/tests/testapi.mm:
(testObjectiveCAPIMain):
(checkNegativeNSIntegers):
(testObjectiveCAPI):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/API/ObjcRuntimeExtras.h (185121 => 185122)
--- trunk/Source/_javascript_Core/API/ObjcRuntimeExtras.h 2015-06-02 21:14:25 UTC (rev 185121)
+++ trunk/Source/_javascript_Core/API/ObjcRuntimeExtras.h 2015-06-02 21:24:10 UTC (rev 185122)
@@ -164,7 +164,7 @@
case 'l':
return DelegateType::template typeInteger<long>();
case 'q':
- return DelegateType::template typeDouble<unsigned long long>();
+ return DelegateType::template typeDouble<long long>();
case 'C':
return DelegateType::template typeInteger<unsigned char>();
case 'I':
Modified: trunk/Source/_javascript_Core/API/tests/testapi.mm (185121 => 185122)
--- trunk/Source/_javascript_Core/API/tests/testapi.mm 2015-06-02 21:14:25 UTC (rev 185121)
+++ trunk/Source/_javascript_Core/API/tests/testapi.mm 2015-06-02 21:24:10 UTC (rev 185122)
@@ -1416,9 +1416,41 @@
runRegress141809();
}
+@protocol NumberProtocol <JSExport>
+
+@property (nonatomic) NSInteger number;
+
+@end
+
+@interface NumberObject : NSObject <NumberProtocol>
+
+@property (nonatomic) NSInteger number;
+
+@end
+
+@implementation NumberObject
+
+@end
+
+// Check that negative NSIntegers retain the correct value when passed into JS code.
+static void checkNegativeNSIntegers()
+{
+ NumberObject *container = [[NumberObject alloc] init];
+ container.number = -1;
+ JSContext *context = [[JSContext alloc] init];
+ context[@"container"] = container;
+ NSString *jsID = @"var getContainerNumber = function() { return container.number }";
+ [context evaluateScript:jsID];
+ JSValue *jsFunction = context[@"getContainerNumber"];
+ JSValue *result = [jsFunction callWithArguments:@[]];
+
+ checkResult(@"Negative number maintained its original value", [[result toString] isEqualToString:@"-1"]);
+}
+
void testObjectiveCAPI()
{
NSLog(@"Testing Objective-C API");
+ checkNegativeNSIntegers();
testWeakValue();
testObjectiveCAPIMain();
}
Modified: trunk/Source/_javascript_Core/ChangeLog (185121 => 185122)
--- trunk/Source/_javascript_Core/ChangeLog 2015-06-02 21:14:25 UTC (rev 185121)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-06-02 21:24:10 UTC (rev 185122)
@@ -1,3 +1,21 @@
+2015-06-02 Keith Miller <keith_mil...@apple.com>
+
+ _javascript_Core: JSExport protocol with an NSInteger property converts negative values to 18446744073709552000
+ https://bugs.webkit.org/show_bug.cgi?id=145563
+
+ Reviewed by Darin Adler.
+
+ The Objective-C bindings were improperly converting negative
+ long long/NSIntegers to 18446744073709552000 because they
+ were converted to unsigned numbers.
+
+ * API/ObjcRuntimeExtras.h:
+ (parseObjCType):
+ * API/tests/testapi.mm:
+ (testObjectiveCAPIMain):
+ (checkNegativeNSIntegers):
+ (testObjectiveCAPI):
+
2015-06-02 Yusuke Suzuki <utatane....@gmail.com>
Heap-use-after-free read of size 4 in _javascript_Core: WTF::StringImpl::isSymbol() (StringImpl.h:496)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes