Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ee96391 authored by Yi Kong's avatar Yi Kong
Browse files

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.
parent d7f82d57
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -35,8 +35,14 @@ void StatsPuller::SetUidMap(const sp<UidMap>& 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;
    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<std::shared_ptr<LogEvent>>* data) {