mirror of
https://github.com/Zygo/bees.git
synced 2025-07-02 08:42:27 +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:
@ -822,7 +822,8 @@ BeesCrawl::peek_front()
|
||||
if (m_extents.empty()) {
|
||||
return BeesFileRange();
|
||||
}
|
||||
return *m_extents.begin();
|
||||
auto rv = *m_extents.begin();
|
||||
return rv;
|
||||
}
|
||||
|
||||
BeesFileRange
|
||||
@ -848,7 +849,8 @@ BeesCrawlState
|
||||
BeesCrawl::get_state()
|
||||
{
|
||||
unique_lock<mutex> lock(m_state_mutex);
|
||||
return m_state;
|
||||
auto rv = m_state;
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user