Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
TestController::platformLibraryPathForTesting() returns inner pointer…
… to autoreleased NSString

<https://webkit.org/b/206018>
<rdar://problem/58449733>

Reviewed by Darin Adler.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::initialize):
- Use WTF::AutodrainedPool to fix remaining autoreleasePool
  leaks.
* WebKitTestRunner/ios/TestControllerIOS.mm:
(WTR::TestController::platformLibraryPathForTesting):
* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::TestController::platformLibraryPathForTesting):
- Retain NSString since these methods return an inner pointer.
  This also only needs to be initialized once.


Canonical link: https://commits.webkit.org/219162@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254318 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
ddkilzer committed Jan 10, 2020
1 parent 45f982b commit d009be4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
19 changes: 19 additions & 0 deletions Tools/ChangeLog
@@ -1,3 +1,22 @@
2020-01-09 David Kilzer <ddkilzer@apple.com>

TestController::platformLibraryPathForTesting() returns inner pointer to autoreleased NSString
<https://webkit.org/b/206018>
<rdar://problem/58449733>

Reviewed by Darin Adler.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::initialize):
- Use WTF::AutodrainedPool to fix remaining autoreleasePool
leaks.
* WebKitTestRunner/ios/TestControllerIOS.mm:
(WTR::TestController::platformLibraryPathForTesting):
* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::TestController::platformLibraryPathForTesting):
- Retain NSString since these methods return an inner pointer.
This also only needs to be initialized once.

2020-01-09 Wenson Hsieh <wenson_hsieh@apple.com>

Text manipulation controller should not observe changes in new replacement elements
Expand Down
2 changes: 2 additions & 0 deletions Tools/WebKitTestRunner/TestController.cpp
Expand Up @@ -442,6 +442,8 @@ const char* TestController::libraryPathForTesting()

void TestController::initialize(int argc, const char* argv[])
{
AutodrainedPool pool;

JSC::initializeThreading();
RunLoop::initializeMainRunLoop();
WTF::setProcessPrivileges(allPrivileges());
Expand Down
7 changes: 6 additions & 1 deletion Tools/WebKitTestRunner/ios/TestControllerIOS.mm
Expand Up @@ -250,7 +250,12 @@ static void handleMenuDidHideNotification(CFNotificationCenterRef, void*, CFStri

const char* TestController::platformLibraryPathForTesting()
{
return [[@"~/Library/Application Support/WebKitTestRunner" stringByExpandingTildeInPath] UTF8String];
static NSString *platformLibraryPath = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
platformLibraryPath = [[@"~/Library/Application Support/WebKitTestRunner" stringByExpandingTildeInPath] retain];
});
return platformLibraryPath.UTF8String;
}

void TestController::setHidden(bool)
Expand Down
7 changes: 6 additions & 1 deletion Tools/WebKitTestRunner/mac/TestControllerMac.mm
Expand Up @@ -377,7 +377,12 @@ static PlatformWindow wtr_NSApplication_keyWindow(id self, SEL _cmd)

const char* TestController::platformLibraryPathForTesting()
{
return [[@"~/Library/Application Support/DumpRenderTree" stringByExpandingTildeInPath] UTF8String];
static NSString *platformLibraryPath = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
platformLibraryPath = [[@"~/Library/Application Support/DumpRenderTree" stringByExpandingTildeInPath] retain];
});
return platformLibraryPath.UTF8String;
}

} // namespace WTR

0 comments on commit d009be4

Please sign in to comment.