RESOLVED FIXED 209145
[Cocoa] Crash under -[WKPreferenceObserver init]
https://bugs.webkit.org/show_bug.cgi?id=209145
Summary [Cocoa] Crash under -[WKPreferenceObserver init]
Per Arne Vollan
Reported 2020-03-16 11:47:58 PDT
A crash has been observed on line 206 in PreferenceObserver.mm: 204 for (auto domain : domains) { 205 auto userDefaults = adoptNS([[WKUserDefaults alloc] initWithSuiteName:domain]); -> 206 userDefaults.get()->m_observer = self;
Attachments
Patch (1.77 KB, patch)
2020-03-16 11:57 PDT, Per Arne Vollan
darin: review+
Per Arne Vollan
Comment 1 2020-03-16 11:48:15 PDT
Per Arne Vollan
Comment 2 2020-03-16 11:57:32 PDT
Darin Adler
Comment 3 2020-03-16 12:45:01 PDT
Comment on attachment 393667 [details] 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.
Per Arne Vollan
Comment 4 2020-03-16 13:12:02 PDT
(In reply to Darin Adler from comment #3) > Comment on attachment 393667 [details] > 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. Fixed. Thanks for reviewing!
Per Arne Vollan
Comment 5 2020-03-16 13:13:07 PDT
Note You need to log in before you can comment on or make changes to this bug.