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

Commit c95fa0f0 authored by Devin Moore's avatar Devin Moore
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
parent aeec1802
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
@@ -166,6 +166,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");