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

Commit 0ca31521 authored by Johan Redestig's avatar Johan Redestig Committed by Marco Nelissen
Browse files

Fix integer overflow in estimateMoovBoxSize

On 200GB SD Card the Camera reported an expected max file duration
of 89158000000 us, this later overflowed the calculation in
estimateMoovBoxSize. Move the division in before the multiplication
to avoid the overflow (this gives different result for <1ms duration
limits but this should not be noticeable in the end).

Change-Id: I53e8238745ef86282483b617df5dcbd3562907fc
parent ab618454
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -594,7 +594,7 @@ int64_t MPEG4Writer::estimateMoovBoxSize(int32_t bitRate) {
    if (mMaxFileDurationLimitUs != 0) {
        if (bitRate > 0) {
            int64_t size2 =
                ((mMaxFileDurationLimitUs * bitRate * 6) / 1000 / 8000000);
                ((mMaxFileDurationLimitUs / 1000) * bitRate * 6) / 8000000;
            if (mMaxFileSizeLimitBytes != 0 && mIsFileSizeLimitExplicitlyRequested) {
                // When both file size and duration limits are set,
                // we use the smaller limit of the two.