Merge pull request #14220 from SamGondelman/pickFree

Fix PickManager::removePick heap use after free
This commit is contained in:
Seth Alves 2018-10-22 09:48:22 -07:00 committed by GitHub
commit a2d4c236c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,11 +38,11 @@ std::shared_ptr<PickQuery> PickManager::findPick(unsigned int uid) const {
void PickManager::removePick(unsigned int uid) {
withWriteLock([&] {
auto type = _typeMap.find(uid);
if (type != _typeMap.end()) {
_picks[type->second].erase(uid);
_typeMap.erase(uid);
_totalPickCounts[type->second]--;
auto typeIt = _typeMap.find(uid);
if (typeIt != _typeMap.end()) {
_picks[typeIt->second].erase(uid);
_totalPickCounts[typeIt->second]--;
_typeMap.erase(typeIt);
}
});
}