diff options
| author | 2017-06-20 12:41:33 -0700 | |
|---|---|---|
| committer | 2017-09-20 17:23:43 -0700 | |
| commit | 3428c7869e40ee1a8807e1692f56a72d9fb2ce91 (patch) | |
| tree | 2698ce0344bfb7298ae762f7721ac976a08f141f | |
| parent | 42a09f10e299816abf5c2c4468f1d883e022300a (diff) | |
Check key before edit value in countFlushCompleteEventsLocked
Fix an unchecked editValueFor that potentially causes log fatal
when sensor is removed from connection shortly before arrival of
flush complete message.
Bug: 62806749
Test: compiles, flush() still working.
Change-Id: I3684251b7bb746b01d0d8849024217c80ad52f9d
Merged-In: I3684251b7bb746b01d0d8849024217c80ad52f9d
| -rw-r--r-- | services/sensorservice/SensorEventConnection.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/services/sensorservice/SensorEventConnection.cpp b/services/sensorservice/SensorEventConnection.cpp index fad046cf53..bfe4c09248 100644 --- a/services/sensorservice/SensorEventConnection.cpp +++ b/services/sensorservice/SensorEventConnection.cpp @@ -477,7 +477,14 @@ void SensorService::SensorEventConnection::countFlushCompleteEventsLocked( // separately before the next batch of events. for (int j = 0; j < numEventsDropped; ++j) { if (scratch[j].type == SENSOR_TYPE_META_DATA) { - FlushInfo& flushInfo = mSensorInfo.editValueFor(scratch[j].meta_data.sensor); + ssize_t index = mSensorInfo.indexOfKey(scratch[j].meta_data.sensor); + if (index < 0) { + ALOGW("%s: sensor 0x%x is not found in connection", + __func__, scratch[j].meta_data.sensor); + continue; + } + + FlushInfo& flushInfo = mSensorInfo.editValueAt(index); flushInfo.mPendingFlushEventsToSend++; ALOGD_IF(DEBUG_CONNECTIONS, "increment pendingFlushCount %d", flushInfo.mPendingFlushEventsToSend); |