dht: prevent potential use-after-free in storageChanged

This commit is contained in:
Adrien Béraud committed 2022-04-15 20:12:48 -04:00
1 parent 92b08bbbc9
commit 9991c976ff
1 file changed
+5 -1
+5 -1
View File
@@ -1282,9 +1282,13 @@ Dht::storageStore(const InfoHash& id, const Sp<Value>& value, time_point created
vs->expiration_job = scheduler.add(expiration, std::bind(&Dht::expireStorage, this, id));
}
if (total_store_size > max_store_size) {
auto value = vs->data;
auto value_diff = store.second.values_diff;
expireStore();
storageChanged(id, st->second, value, value_diff > 0);
} else {
storageChanged(id, st->second, vs->data, store.second.values_diff > 0);
}
storageChanged(id, st->second, vs->data, store.second.values_diff > 0);
}
return std::get<0>(store);