Mirror von
https://github.com/tkuschel/bees.git
synchronisiert 2026-05-08 04:59:37 +02:00
crucible: cache: construct return value before releasing lock
If we release the lock first (and C++ destructor order says we do), then the return value will be constructed from data living in an unprotected container object. That data might be destroyed before we get to the copy constructor for the return value. Make a temporary copy of the return value that won't be destroyed by any other thread, then unlock the mutex, then return the copy object. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
Dieser Commit ist enthalten in:
@@ -154,7 +154,9 @@ namespace crucible {
|
||||
if (!inserted) {
|
||||
found->second.first = m_ctr++;
|
||||
}
|
||||
return found->second.second;
|
||||
// Make copy before releasing lock
|
||||
auto rv = found->second.second;
|
||||
return rv;
|
||||
}
|
||||
|
||||
template<class Return, class... Arguments>
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren