Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Cocoa] Return early from preference change notification handler if t…
…here is no observer

https://bugs.webkit.org/show_bug.cgi?id=213050

Reviewed by Darin Adler.

Currently, the observer member is checked inside the loop iterating over all the keys,
but this check should be moved outside of the loop.

No new tests, since this is not a change in behavior.

* UIProcess/Cocoa/PreferenceObserver.mm:
(-[WKUserDefaults _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:]):


Canonical link: https://commits.webkit.org/225834@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262865 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
pvollan committed Jun 10, 2020
1 parent 28af726 commit 7944d31
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions Source/WebKit/ChangeLog
@@ -1,3 +1,18 @@
2020-06-10 Per Arne Vollan <pvollan@apple.com>

[Cocoa] Return early from preference change notification handler if there is no observer
https://bugs.webkit.org/show_bug.cgi?id=213050

Reviewed by Darin Adler.

Currently, the observer member is checked inside the loop iterating over all the keys,
but this check should be moved outside of the loop.

No new tests, since this is not a change in behavior.

* UIProcess/Cocoa/PreferenceObserver.mm:
(-[WKUserDefaults _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:]):

2020-06-10 Brady Eidson <beidson@apple.com>

Crash growing a CFData with incremental PDF loading.
Expand Down
6 changes: 3 additions & 3 deletions Source/WebKit/UIProcess/Cocoa/PreferenceObserver.mm
Expand Up @@ -49,6 +49,9 @@ - (void)_notifyObserversOfChangeFromValuesForKeys:(NSDictionary<NSString *, id>
{
[super _notifyObserversOfChangeFromValuesForKeys:oldValues toValuesForKeys:newValues];

if (!m_observer)
return;

for (NSString *key in oldValues) {
id oldValue = oldValues[key];
id newValue = newValues[key];
Expand All @@ -68,9 +71,6 @@ - (void)_notifyObserversOfChangeFromValuesForKeys:(NSDictionary<NSString *, id>
encodedString = [data base64EncodedStringWithOptions:0];
}

if (!m_observer)
return;

auto globalValue = adoptCF(CFPreferencesCopyValue((__bridge CFStringRef)key, kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
auto domainValue = adoptCF(CFPreferencesCopyValue((__bridge CFStringRef)key, (__bridge CFStringRef)m_suiteName, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));

Expand Down

0 comments on commit 7944d31

Please sign in to comment.