Fix MSVC warning C4172 in ModifySafeMap::get (#14576)

This commit is contained in:
JosiahWI 2024-04-23 12:04:26 -05:00 committed by GitHub
parent 98fd5bd453
commit de8d80dee0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 1 deletions

View File

@ -369,7 +369,14 @@ public:
return it->second;
}
auto it = m_values.find(key);
return it == m_values.end() ? null_value : it->second;
// This conditional block was converted from a ternary to ensure no
// temporary values are created in evaluating the return expression,
// which could cause a dangling reference.
if (it != m_values.end()) {
return it->second;
} else {
return null_value;
}
}
void put(const K &key, const V &value) {