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

Commit cf83b16a authored by Devin Moore's avatar Devin Moore Committed by Cherrypicker Worker
Browse files

Remove some new memory leaks from SensorManager

After catching an error in Sensor::unflatten, there are memory leaks
caught by the fuzzer in the same test case.

Test: libsensorserviceaidl_fuzzer with testcase from bug
Bug: 269014004
Merged-In: I509cceb41f56ca117d9475f6f6674244560fe582
Change-Id: I509cceb41f56ca117d9475f6f6674244560fe582
(cherry picked from commit c95fa0f0)
Merged-In: I509cceb41f56ca117d9475f6f6674244560fe582
parent 54aacdf9
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -66,7 +66,11 @@ public:
        v.setCapacity(n);
        while (n) {
            n--;
            reply.read(s);
            if(reply.read(s) != OK) {
                ALOGE("Failed to read reply from getSensorList");
                v.clear();
                break;
            }
            v.add(s);
        }
        return v;
@@ -84,7 +88,11 @@ public:
        v.setCapacity(n);
        while (n) {
            n--;
            reply.read(s);
            if(reply.read(s) != OK) {
                ALOGE("Failed to read reply from getDynamicSensorList");
                v.clear();
                break;
            }
            v.add(s);
        }
        return v;
+5 −0
Original line number Diff line number Diff line
@@ -162,6 +162,11 @@ status_t SensorManager::assertStateLocked() {

        mSensors = mSensorServer->getSensorList(mOpPackageName);
        size_t count = mSensors.size();
        if (count == 0) {
            ALOGE("Failed to get Sensor list");
            mSensorServer.clear();
            return UNKNOWN_ERROR;
        }
        mSensorList =
                static_cast<Sensor const**>(malloc(count * sizeof(Sensor*)));
        LOG_ALWAYS_FATAL_IF(mSensorList == nullptr, "mSensorList NULL");