[webkit-reviews] review granted: [Bug 209145] [Cocoa] Crash under -[WKPreferenceObserver init] : [Attachment 393667] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Mar 16 12:45:01 PDT 2020


Darin Adler <darin at apple.com> has granted Per Arne Vollan <pvollan at apple.com>'s
request for review:
Bug 209145: [Cocoa] Crash under -[WKPreferenceObserver init]
https://bugs.webkit.org/show_bug.cgi?id=209145

Attachment 393667: Patch

https://bugs.webkit.org/attachment.cgi?id=393667&action=review




--- Comment #3 from Darin Adler <darin at apple.com> ---
Comment on attachment 393667
  --> https://bugs.webkit.org/attachment.cgi?id=393667
Patch

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

> Source/WebKit/UIProcess/Cocoa/PreferenceObserver.mm:206
> -	   auto userDefaults = adoptNS([[WKUserDefaults alloc]
initWithSuiteName:domain]);
> +	   auto userDefaults = adoptNS([WKUserDefaults alloc]);
> +	   if (![userDefaults initWithSuiteName:domain]) {

This is the wrong way to write it. Leave the code as is and write it like this:

    auto userDefaults = adoptNS([[WKUserDefaults alloc]
initWithSuiteName:domain]);
    if (!userDefaults) {

The adoptNS function already handles everything correctly.


More information about the webkit-reviews mailing list