Fix double free
Summary: It was possible for transaction to be double freed because both the AllClear and SingleClear of transactions could delete the pointer Reviewers: florijan, mferencevic Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1250
This commit is contained in:
parent
a826f41444
commit
79dc10960e
@ -134,8 +134,10 @@ void WorkerEngine::ClearTransactionalCache(
|
|||||||
auto access = active_.access();
|
auto access = active_.access();
|
||||||
for (auto kv : access) {
|
for (auto kv : access) {
|
||||||
if (kv.first < oldest_active) {
|
if (kv.first < oldest_active) {
|
||||||
delete kv.second;
|
auto transaction_ptr = kv.second;
|
||||||
access.remove(kv.first);
|
if (access.remove(kv.first)) {
|
||||||
|
delete transaction_ptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,8 +146,10 @@ void WorkerEngine::ClearSingleTransaction(transaction_id_t tx_id) const {
|
|||||||
auto access = active_.access();
|
auto access = active_.access();
|
||||||
auto found = access.find(tx_id);
|
auto found = access.find(tx_id);
|
||||||
if (found != access.end()) {
|
if (found != access.end()) {
|
||||||
delete found->second;
|
auto transaction_ptr = found->second;
|
||||||
access.remove(found->first);
|
if (access.remove(found->first)) {
|
||||||
|
delete transaction_ptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user