Crash fix for ResourceCache::getResource()

A wrong 'read' locker is used around a critical section that actually modifies the _resources QHash.
This can result in memory corruption and seg faults.
This commit is contained in:
Anthony J. Thibault 2019-06-10 15:05:34 -07:00
parent 2b90d841b7
commit 654b5775e1

View file

@ -346,7 +346,7 @@ void ResourceCache::setRequestLimit(uint32_t limit) {
QSharedPointer<Resource> ResourceCache::getResource(const QUrl& url, const QUrl& fallback, void* extra, size_t extraHash) {
QSharedPointer<Resource> resource;
{
QReadLocker locker(&_resourcesLock);
QWriteLocker locker(&_resourcesLock);
auto& resourcesWithExtraHash = _resources[url];
auto resourcesWithExtraHashIter = resourcesWithExtraHash.find(extraHash);
if (resourcesWithExtraHashIter != resourcesWithExtraHash.end()) {