diff options
| author | 2017-11-06 11:08:01 -0800 | |
|---|---|---|
| committer | 2017-12-20 15:21:40 -0800 | |
| commit | 7aafa16f0cd6761f9820c9498c8ada304e2f06b1 (patch) | |
| tree | 6b76faee16237a1741032ec2fa05df0906581da8 | |
| parent | 1a49778eccfeea3614465e83c53b66f786ecad32 (diff) | |
Fix sensorservice on integer sanitized builds.
Refactors unsigned integer overflows in cleanupImpl to fix integer
overflow sanitized builds.
Test: Compiled and checked output from sanitizer.
Bug: 30969751
Change-Id: I1c13b4b7b524d40b5732af8c36107cda9388c9ec
Merged-In: I1c13b4b7b524d40b5732af8c36107cda9388c9ec
| -rw-r--r-- | services/sensorservice/BatteryService.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/services/sensorservice/BatteryService.cpp b/services/sensorservice/BatteryService.cpp index 452c8c64b0..330861d5dc 100644 --- a/services/sensorservice/BatteryService.cpp +++ b/services/sensorservice/BatteryService.cpp @@ -78,12 +78,13 @@ void BatteryService::cleanupImpl(uid_t uid) { if (checkService()) { Mutex::Autolock _l(mActivationsLock); int64_t identity = IPCThreadState::self()->clearCallingIdentity(); - for (size_t i=0 ; i<mActivations.size() ; i++) { + for (size_t i=0 ; i<mActivations.size() ; ) { const Info& info(mActivations[i]); if (info.uid == uid) { mBatteryStatService->noteStopSensor(info.uid, info.handle); mActivations.removeAt(i); - i--; + } else { + i++; } } IPCThreadState::self()->restoreCallingIdentity(identity); @@ -105,4 +106,3 @@ ANDROID_SINGLETON_STATIC_INSTANCE(BatteryService) // --------------------------------------------------------------------------- }; // namespace android - |