Bug 186865

Summary: Fix leaks in WebCore found by clang static analyzer in deep mode
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: WebCore Misc.Assignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, eric.carlson, ews-watchlist, jiewen_tan, joepeck, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch v1
none
Archive of layout-test-results from ews106 for mac-sierra-wk2 none

Description David Kilzer (:ddkilzer) 2018-06-20 15:49:11 PDT
Fix leaks in WebCore found by clang static analyzer in deep mode.
Comment 1 David Kilzer (:ddkilzer) 2018-06-20 15:56:05 PDT
Created attachment 343186 [details]
Patch v1
Comment 2 David Kilzer (:ddkilzer) 2018-06-20 15:58:55 PDT
Comment on attachment 343186 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=343186&action=review

> Source/WebCore/platform/mac/WebCoreNSURLExtras.mm:783
> +    if (![hostNameRanges count]) {
> +        [hostNameRanges release];
>          return nil;
> +    }

I considered changing the `hostNameRanges` declaration from this:

    NSMutableArray *hostNameRanges = nil;

To this:

    RetainPtr<NSMutableArray> hostNameRanges;

And then change functions to take a RetainPtr<NSMutableArray>& instead of NSMutableArray **.

I'm happy to do that instead, although I didn't want to overthink the change.
Comment 3 Joseph Pecoraro 2018-06-20 16:01:43 PDT
Comment on attachment 343186 [details]
Patch v1

r=me
Comment 4 EWS Watchlist 2018-06-20 16:46:05 PDT
Comment on attachment 343186 [details]
Patch v1

Attachment 343186 [details] did not pass mac-wk2-ews (mac-wk2):
Output: https://webkit-queues.webkit.org/results/8270290

New failing tests:
accessibility/mac/selection-notification-focus-change.html
Comment 5 EWS Watchlist 2018-06-20 16:46:06 PDT
Created attachment 343190 [details]
Archive of layout-test-results from ews106 for mac-sierra-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews106  Port: mac-sierra-wk2  Platform: Mac OS X 10.12.6
Comment 6 David Kilzer (:ddkilzer) 2018-06-20 19:38:27 PDT
(In reply to Build Bot from comment #4)
> Comment on attachment 343186 [details]
> Patch v1
> 
> Attachment 343186 [details] did not pass mac-wk2-ews (mac-wk2):
> Output: https://webkit-queues.webkit.org/results/8270290
> 
> New failing tests:
> accessibility/mac/selection-notification-focus-change.html

Looks flakey to me without this change:
<https://webkit-test-results.webkit.org/dashboards/flakiness_dashboard.html#tests=accessibility%2Fmac%2Fselection-notification-focus-change.html>
Comment 7 WebKit Commit Bot 2018-06-20 20:05:02 PDT
Comment on attachment 343186 [details]
Patch v1

Clearing flags on attachment: 343186

Committed r233029: <https://trac.webkit.org/changeset/233029>
Comment 8 WebKit Commit Bot 2018-06-20 20:05:04 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Radar WebKit Bug Importer 2018-06-20 20:06:27 PDT
<rdar://problem/41315464>