Bug 176268 - Web Automation: -[_WKAutomationSession init] leaks
Summary: Web Automation: -[_WKAutomationSession init] leaks
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-09-01 21:06 PDT by Joseph Pecoraro
Modified: 2017-09-27 12:39 PDT (History)
5 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (1.26 KB, patch)
2017-09-01 21:19 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2017-09-01 21:06:51 PDT
Web Automation: -[_WKAutomationSession init] leaks:

> - (instancetype)init
> {
>     return [self initWithConfiguration:[_WKAutomationSessionConfiguration new]];
> }

because we are not in ARC, the -new is a +1 but we should be passing an autoreleased object here.

This was caught by the static analyzer.

Test:

> // shell> xcrun clang -framework Foundation -framework WebKit leak.m
> 
> #import <WebKit/WebKit.h>
> @interface _WKAutomationSession : NSObject
> @end
> 
> static void leak() {
>     [[[_WKAutomationSession alloc] init] release];
> }
> 
> int main() {
>     @autoreleasepool { leak(); }
>     sleep(1000);
>     return 0;
> }

Leak:

Process 68184: 1 leak for 16 total leaked bytes.
Leak: 0x7fdd1b506ff0  size=16  zone: DefaultMallocZone_0x112fbd000   _WKAutomationSessionConfiguration  ObjC  WebKit
	0x0eb156d9 0x001d8001 0x00000001 0x00000000 	.V..............
	Call stack: [thread 0x7fffa41cc340]: 
        | 0x1 
        | start 
        | main 
        | leak 
        | -[_WKAutomationSession init] _WKAutomationSession.mm:46 
        | +[NSObject new] 
        | class_createInstance 
        | calloc 
        | malloc_zone_calloc
Comment 1 Joseph Pecoraro 2017-09-01 21:19:59 PDT
Created attachment 319689 [details]
[PATCH] Proposed Fix
Comment 2 WebKit Commit Bot 2017-09-02 11:29:43 PDT
Comment on attachment 319689 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 319689

Committed r221538: <http://trac.webkit.org/changeset/221538>
Comment 3 WebKit Commit Bot 2017-09-02 11:29:45 PDT
All reviewed patches have been landed.  Closing bug.
Comment 4 Radar WebKit Bug Importer 2017-09-27 12:39:34 PDT
<rdar://problem/34693703>