Don't use invalidated ResourceLoadStatistics iterators
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 May 2016 15:53:10 +0000 (15:53 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 May 2016 15:53:10 +0000 (15:53 +0000)
commitede997a2b779018e50cf00db03bd571bbe2b8b6c
treec42f86bc4dc12ec2ab025ddd5342412958897370
parentdd6a7c7ef876890178b08058023abcde66909330
Don't use invalidated ResourceLoadStatistics iterators
https://bugs.webkit.org/show_bug.cgi?id=157412
<rdar://problem/26133153>

Reviewed by Chris Dumez.

ResourceLoadObserver::logFrameNavigation was using references bound to the 'value'
member of iterators from the ResourceLoadStatistics HashMap. When new entries were
added, these iterators were invalidated causing the references to refer to invalid
memory.

Renamed 'resourceStatisticsForPrimaryDomain' to 'ensureResourceStatisticsForPrimaryDomain'
to clarify that it may mutate the underlying HashMap, thereby invalidating any
existing iterators.

* loader/ResourceLoadObserver.cpp:
(WebCore::ResourceLoadObserver::logFrameNavigation): Protect against HashMap
elements being copied/moved when new intries are added.
* loader/ResourceLoadStatisticsStore.cpp:
(WebCore::ResourceLoadStatisticsStore::setResourceStatisticsForPrimaryDomain): Added.
* loader/ResourceLoadStatisticsStore.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200511 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/loader/ResourceLoadObserver.cpp
Source/WebCore/loader/ResourceLoadStatisticsStore.cpp
Source/WebCore/loader/ResourceLoadStatisticsStore.h