Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 42cdc42

Browse files
Crash under WebCookieCache::clearForHost()
https://bugs.webkit.org/show_bug.cgi?id=209149 <rdar://problem/60453086> Reviewed by Darin Adler. Alternative fix for Bug 209149 based on comments from Darin. * WebProcess/WebPage/WebCookieCache.cpp: (WebKit::WebCookieCache::clearForHost): (WebKit::WebCookieCache::pruneCacheIfNecessary): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@258530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 9cc7d2e commit 42cdc42

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

Source/WebKit/ChangeLog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2020-03-16 Chris Dumez <[email protected]>
2+
3+
Crash under WebCookieCache::clearForHost()
4+
https://bugs.webkit.org/show_bug.cgi?id=209149
5+
<rdar://problem/60453086>
6+
7+
Reviewed by Darin Adler.
8+
9+
Alternative fix for Bug 209149 based on comments from Darin.
10+
11+
* WebProcess/WebPage/WebCookieCache.cpp:
12+
(WebKit::WebCookieCache::clearForHost):
13+
(WebKit::WebCookieCache::pruneCacheIfNecessary):
14+
115
2020-03-16 Tim Horton <[email protected]>
216

317
Fix the macCatalyst build after r258525

Source/WebKit/WebProcess/WebPage/WebCookieCache.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,13 @@ void WebCookieCache::clear()
102102

103103
void WebCookieCache::clearForHost(const String& host)
104104
{
105-
auto it = m_hostsWithInMemoryStorage.find(host);
106-
if (it == m_hostsWithInMemoryStorage.end())
105+
String removedHost = m_hostsWithInMemoryStorage.take(host);
106+
if (removedHost.isNull())
107107
return;
108108

109-
m_hostsWithInMemoryStorage.remove(it);
110-
inMemoryStorageSession().deleteCookiesForHostnames(Vector<String> { host });
109+
inMemoryStorageSession().deleteCookiesForHostnames(Vector<String> { removedHost });
111110
#if HAVE(COOKIE_CHANGE_LISTENER_API)
112-
WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::UnsubscribeFromCookieChangeNotifications(HashSet<String> { host }), 0);
111+
WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::UnsubscribeFromCookieChangeNotifications(HashSet<String> { removedHost }), 0);
113112
#endif
114113
}
115114

@@ -118,10 +117,8 @@ void WebCookieCache::pruneCacheIfNecessary()
118117
// We may want to raise this limit if we start using the cache for third-party iframes.
119118
static const unsigned maxCachedHosts = 5;
120119

121-
while (m_hostsWithInMemoryStorage.size() >= maxCachedHosts) {
122-
String hostToRemove = *m_hostsWithInMemoryStorage.random();
123-
clearForHost(hostToRemove);
124-
}
120+
while (m_hostsWithInMemoryStorage.size() >= maxCachedHosts)
121+
clearForHost(*m_hostsWithInMemoryStorage.random());
125122
}
126123

127124
#if !PLATFORM(COCOA)

0 commit comments

Comments
 (0)