mirror of
https://github.com/Zygo/bees.git
synced 2025-06-16 17:46:16 +02:00
bees: fix further instances of copy-after-unlock bug
Before: unique_lock<mutex> lock(some_mutex); // run lock.~unique_lock() because return // return reference to unprotected heap return foo[bar]; After: unique_lock<mutex> lock(some_mutex); // make copy of object on heap protected by mutex lock auto tmp_copy = foo[bar]; // run lock.~unique_lock() because return // pass locally allocated object to copy constructor return tmp_copy; Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
@ -286,7 +286,8 @@ Fd
|
||||
BeesFileRange::fd() const
|
||||
{
|
||||
unique_lock<mutex> lock(s_mutex);
|
||||
return m_fd;
|
||||
auto rv = m_fd;
|
||||
return rv;
|
||||
}
|
||||
|
||||
Fd
|
||||
@ -310,7 +311,8 @@ BeesFileRange::fd(const shared_ptr<BeesContext> &ctx) const
|
||||
}
|
||||
}
|
||||
// We either had a fid and opened it, or we didn't and we're just stuck with our fd
|
||||
return m_fd;
|
||||
auto rv = m_fd;
|
||||
return rv;
|
||||
}
|
||||
|
||||
BeesFileRange
|
||||
|
Reference in New Issue
Block a user