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

Commit fb42ae81 authored by Roman Kiryanov's avatar Roman Kiryanov
Browse files

Fix iterating over cameras in media profiles initialization



The loop used to go through camera id indexes
while calling it `cameraId`. This caused a crash
and bootloop if an index was not present in
`mCameraIds` (e.g. if `mCameraIds` is an array
of one element other than zero).

Bug: 269194950
Test: presubmit
Change-Id: I12b3058b0f1728d0127873c7362dceef9ddd3cd9
Signed-off-by: default avatarRoman Kiryanov <rkir@google.com>
parent dab56ccf
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -898,10 +898,9 @@ void MediaProfiles::checkAndAddRequiredProfilesIfNecessary() {
        }
    }

    for (size_t cameraId = 0; cameraId < mCameraIds.size(); ++cameraId) {
    for (size_t refIndex = 0; refIndex < mCameraIds.size(); ++refIndex) {
        const int cameraId = mCameraIds[refIndex];
        for (size_t j = 0; j < kNumRequiredProfiles; ++j) {
            int refIndex = getRequiredProfileRefIndex(cameraId);
            CHECK(refIndex != -1);
            RequiredProfileRefInfo *info =
                    &mRequiredProfileRefs[refIndex].mRefs[j];

@@ -931,14 +930,14 @@ void MediaProfiles::checkAndAddRequiredProfilesIfNecessary() {

                int index = getCamcorderProfileIndex(cameraId, profile->mQuality);
                if (index != -1) {
                    ALOGV("Profile quality %d for camera %zu already exists",
                    ALOGV("Profile quality %d for camera %d already exists",
                        profile->mQuality, cameraId);
                    CHECK(index == refIndex);
                    continue;
                }

                // Insert the new profile
                ALOGV("Add a profile: quality %d=>%d for camera %zu",
                ALOGV("Add a profile: quality %d=>%d for camera %d",
                        mCamcorderProfiles[info->mRefProfileIndex]->mQuality,
                        profile->mQuality, cameraId);