Bug 210658

Summary: REGRESSION (r234105): [iOS] WKColorButton leaks a UIColor
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: WebKit2Assignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, darin, esprehn+autocc, ews-watchlist, gyuyoung.kim, mifenton, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 187871    
Bug Blocks:    
Attachments:
Description Flags
Patch v1
none
Patch for landing none

Description David Kilzer (:ddkilzer) 2020-04-17 09:26:21 PDT
WKColorButton leaks a UIColor.

Found by clang static analyzer:

'WKColorButton' lacks a 'dealloc' instance method but must release '_color'

--

#pragma mark - WKColorButton

@interface WKColorButton : UIButton
@property (nonatomic, strong) UIColor *color;

+ (instancetype)colorButtonWithColor:(UIColor *)color;
@end

@implementation WKColorButton

+ (instancetype)colorButtonWithColor:(UIColor *)color
{
    WKColorButton *colorButton = [WKColorButton buttonWithType:UIButtonTypeCustom];
    colorButton.color = color;
    colorButton.backgroundColor = color;
    return colorButton;
}

@end
Comment 1 Radar WebKit Bug Importer 2020-04-17 09:27:32 PDT
<rdar://problem/61938137>
Comment 2 David Kilzer (:ddkilzer) 2020-04-17 09:31:30 PDT
Created attachment 396770 [details]
Patch v1
Comment 3 Darin Adler 2020-04-17 10:15:28 PDT
Comment on attachment 396770 [details]
Patch v1

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

> Source/WebCore/page/Chrome.cpp:428
>  #if PLATFORM(IOS_FAMILY)
>      return nullptr;
> -#endif
> +#else
>      notifyPopupOpeningObservers();
>      return m_client.createColorChooser(client, initialColor);
> +#endif

We need UNUSED_PARAM here.

I also think the "always-null color chooser" design strategy is a little messy, but that goes beyond this function
Comment 4 David Kilzer (:ddkilzer) 2020-04-17 14:42:16 PDT
Created attachment 396803 [details]
Patch for landing
Comment 5 EWS 2020-04-17 15:08:36 PDT
Committed r260290: <https://trac.webkit.org/changeset/260290>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 396803 [details].