fix: Sender::tick accesses parent->diags_ without lock — data race / use-after-free
This commit is contained in:
@@ -1234,9 +1234,14 @@ void PIConnection::Sender::tick(int) {
|
|||||||
if (data.isEmpty()) return;
|
if (data.isEmpty()) return;
|
||||||
// piCoutObj << "write"<<data.size()<<"bytes to"<<devices.size()<<"devices";
|
// piCoutObj << "write"<<data.size()<<"bytes to"<<devices.size()<<"devices";
|
||||||
for (PIIODevice * d: devices) {
|
for (PIIODevice * d: devices) {
|
||||||
int ret = d->write(data);
|
int ret = d->write(data);
|
||||||
PIDiagnostics * diag = parent->diags_.value(d, nullptr);
|
if (ret > 0) {
|
||||||
if (diag && ret > 0) diag->sended(ret);
|
PIDiagnostics * diag = nullptr;
|
||||||
|
__device_pool__->lock();
|
||||||
|
diag = parent->diags_.value(d, nullptr);
|
||||||
|
__device_pool__->unlock();
|
||||||
|
if (diag) diag->sended(ret);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user