Title: [218694] trunk/Tools
- Revision
- 218694
- Author
- [email protected]
- Date
- 2017-06-22 06:14:59 -0700 (Thu, 22 Jun 2017)
Log Message
[TestWebKitAPI] Fix misuse of -[NSData dataWithBytesNoCopy:length:] with global variables
<https://webkit.org/b/173690>
Reviewed by Chris Dumez.
Per documentation, -[NSData dataWithBytesNoCopy:length:] takes
ownership of malloc()-ed memory, then frees it when it's
released. These tests were passing global variables into the
method, which is not malloc()-ed memory, which violates the API
contract.
The fix is to switch to use
-[NSData dataWithBytesNoCopy:length:freeWhenDone:] and to pass
NO for the last argument.
Caught by the clang static analyzer.
* TestWebKitAPI/Tests/WebKit2Cocoa/IconLoadingDelegate.mm:
(TEST):
* TestWebKitAPI/Tests/WebKit2Cocoa/WKURLSchemeHandler-1.mm:
(TEST):
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (218693 => 218694)
--- trunk/Tools/ChangeLog 2017-06-22 13:01:03 UTC (rev 218693)
+++ trunk/Tools/ChangeLog 2017-06-22 13:14:59 UTC (rev 218694)
@@ -1,3 +1,27 @@
+2017-06-22 David Kilzer <[email protected]>
+
+ [TestWebKitAPI] Fix misuse of -[NSData dataWithBytesNoCopy:length:] with global variables
+ <https://webkit.org/b/173690>
+
+ Reviewed by Chris Dumez.
+
+ Per documentation, -[NSData dataWithBytesNoCopy:length:] takes
+ ownership of malloc()-ed memory, then frees it when it's
+ released. These tests were passing global variables into the
+ method, which is not malloc()-ed memory, which violates the API
+ contract.
+
+ The fix is to switch to use
+ -[NSData dataWithBytesNoCopy:length:freeWhenDone:] and to pass
+ NO for the last argument.
+
+ Caught by the clang static analyzer.
+
+ * TestWebKitAPI/Tests/WebKit2Cocoa/IconLoadingDelegate.mm:
+ (TEST):
+ * TestWebKitAPI/Tests/WebKit2Cocoa/WKURLSchemeHandler-1.mm:
+ (TEST):
+
2017-06-22 Carlos Garcia Campos <[email protected]>
[GTK] Upgrade Harfbuzz to version 1.4.2
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IconLoadingDelegate.mm (218693 => 218694)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IconLoadingDelegate.mm 2017-06-22 13:01:03 UTC (rev 218693)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IconLoadingDelegate.mm 2017-06-22 13:14:59 UTC (rev 218694)
@@ -142,7 +142,7 @@
{
RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
- RetainPtr<IconLoadingSchemeHandler> handler = adoptNS([[IconLoadingSchemeHandler alloc] initWithData:[NSData dataWithBytesNoCopy:(void*)mainBytes length:sizeof(mainBytes)]]);
+ RetainPtr<IconLoadingSchemeHandler> handler = adoptNS([[IconLoadingSchemeHandler alloc] initWithData:[NSData dataWithBytesNoCopy:(void*)mainBytes length:sizeof(mainBytes) freeWhenDone:NO]]);
[configuration setURLSchemeHandler:handler.get() forURLScheme:@"testing"];
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -163,7 +163,7 @@
{
RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
- NSData *mainData = [NSData dataWithBytesNoCopy:(void*)mainBytes2 length:sizeof(mainBytes2)];
+ NSData *mainData = [NSData dataWithBytesNoCopy:(void*)mainBytes2 length:sizeof(mainBytes2) freeWhenDone:NO];
RetainPtr<IconLoadingSchemeHandler> handler = adoptNS([[IconLoadingSchemeHandler alloc] initWithData:mainData]);
NSURL *url = "" mainBundle] URLForResource:@"large-red-square-image" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKURLSchemeHandler-1.mm (218693 => 218694)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKURLSchemeHandler-1.mm 2017-06-22 13:01:03 UTC (rev 218693)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKURLSchemeHandler-1.mm 2017-06-22 13:14:59 UTC (rev 218694)
@@ -106,7 +106,7 @@
RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
- RetainPtr<SchemeHandler> handler = adoptNS([[SchemeHandler alloc] initWithData:[NSData dataWithBytesNoCopy:(void*)mainBytes length:sizeof(mainBytes)] mimeType:@"text/html"]);
+ RetainPtr<SchemeHandler> handler = adoptNS([[SchemeHandler alloc] initWithData:[NSData dataWithBytesNoCopy:(void*)mainBytes length:sizeof(mainBytes) freeWhenDone:NO] mimeType:@"text/html"]);
[configuration setURLSchemeHandler:handler.get() forURLScheme:@"testing"];
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -131,7 +131,7 @@
RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
- RetainPtr<SchemeHandler> handler = adoptNS([[SchemeHandler alloc] initWithData:[NSData dataWithBytesNoCopy:(void*)mainBytes length:sizeof(mainBytes)] mimeType:nil]);
+ RetainPtr<SchemeHandler> handler = adoptNS([[SchemeHandler alloc] initWithData:[NSData dataWithBytesNoCopy:(void*)mainBytes length:sizeof(mainBytes) freeWhenDone:NO] mimeType:nil]);
[configuration setURLSchemeHandler:handler.get() forURLScheme:@"testing"];
RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes