From: Yi Kong Date: Thu, 8 Aug 2019 00:02:22 +0000 (-0700) Subject: Fix statsd ASAN failure X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=3ee963917f05b00b888ce4a6fc6b3df0a190a1c4;p=android-x86%2Fframeworks-base.git Fix statsd ASAN failure If tagId is not found in kAllPullAtomInfo map, StatsPuller will read outside of the object. Add a condition check to gracefully handle unrecognised tagId and fix the ASAN failure. Bug: 139037732 Test: boot aosp_x86-eng Change-Id: Ic62b89866dbec82f05e6f8e6afca9b312f44a801 Merged-In: I5db561c4223efc4ef6b1441490d319cc6ec8afc7 Exempt-From-Owner-Approval: trivial change, owner OOO. --- diff --git a/cmds/statsd/src/external/StatsPuller.cpp b/cmds/statsd/src/external/StatsPuller.cpp index b29e979b5236..8233eeec06c7 100644 --- a/cmds/statsd/src/external/StatsPuller.cpp +++ b/cmds/statsd/src/external/StatsPuller.cpp @@ -35,8 +35,14 @@ void StatsPuller::SetUidMap(const sp& uidMap) { mUidMap = uidMap; } // ValueMetric has a minimum bucket size of 10min so that we don't pull too frequently StatsPuller::StatsPuller(const int tagId) : mTagId(tagId) { - mCoolDownNs = StatsPullerManagerImpl::kAllPullAtomInfo.find(tagId)->second.coolDownNs; - VLOG("Puller for tag %d created. Cooldown set to %lld", mTagId, (long long)mCoolDownNs); + auto pullAtomInfo = StatsPullerManagerImpl::kAllPullAtomInfo.find(tagId); + if (pullAtomInfo != StatsPullerManagerImpl::kAllPullAtomInfo.end()) { + mCoolDownNs = pullAtomInfo->second.coolDownNs; + VLOG("Puller for tag %d created. Cooldown set to %lld", mTagId, (long long)mCoolDownNs); + } else { + mCoolDownNs = 0; + VLOG("Creating puller for a non-recognised tag %d.", mTagId); + } } bool StatsPuller::Pull(const int64_t elapsedTimeNs, std::vector>* data) {