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

Commit 5d59fe12 authored by Girish's avatar Girish
Browse files

MediaCodec: fix an overflow error

Bug: 382739177
Test: ccodec_unit_test
      atest CtsMediaMiscTestCases:android.media.misc.cts.ResourceManagerTest#testCodecAvailability
Change-Id: Ic4a5f6cddf8ca26b912d85aa5de6915d06f295e4
parent 0551055b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1248,6 +1248,11 @@ status_t MediaCodec::getGloballyAvailableResources(std::vector<GlobalResourceInf
                                         return item.type == type; });

            if (used != currentResourceUsage.end() && used->value > 0) {
                if (res.mAvailable < used->value) {
                    ALOGW("%s: Resources used (%jd) is more than the Resource Capacity (%jd)!",
                          __func__, used->value, res.mAvailable);
                    continue;
                }
                // Exclude the used resources.
                res.mAvailable -= used->value;
            }